Right, so I am working on a service that replaces a single part in an existing workflow. The workflow itself has been in existence for, like, 30 years and really, I’m not prepared to go down the path of explaining why the whole thing isn’t being replaced with a shiny new integrated and up-to-date system. Just accept that and move on to today’s interesting point. At the beginning of the part I’m working on, we have to go fetch some structured data from an outside source. This data is available as files, and must be transferred via ftps, with user/password authentication. Once we’ve got this data, we can slurp it into our own database, transform it, and use it for our purposes. Our service is running as a Vapor application so it can provide a nice REST API for the client software and the person using the service doesn’t have to have the database running on their desktop computer, and all the other goodness that comes from a remote service.
Now, it turns out that the FTP server has a certificate that everyone thinks is sketchy. It’s self-signed, I think. Anyway, that just means that plain use of the FTPS URL won’t work; the client needs to start off by saying that the server’s certificate is okay. So, how do I set this up? Right now, during development, I just use FileZilla to fetch the files to my laptop, then use the REST client to upload them to the server. Oh, and I also need to translate one of the files from latin-1 to UTF-8 before I do that.
My first thought is, “This sounds like a job for a periodic worker thread, or at least for a task that gets spun up in response to a client request.” So I started looking for how to do it in Swift.
All of the instructions and demos are for iOS and use Apple’s security stuff that doesn’t get distributed on Windows or Linux.
The consensus seems to be, “Do it with curl.” So, yeah. Swift on the server is totally here for me, unless I want to make nontrivial off-server requests. Then it just takes a smoke break and tells me to introduce a runtime dependency which is probably not a problem at all.