Download the OpenSSL source from here, or for older versions: here, and put it in the same folder as the script. Expand the OpenSSL .gz file, so now you will have a script file, the .gz file and a folder with the OpenSSL source.
For the modifications that follow, I find Sublime Text is an excellent editor. You can just use TextEdit, if you so choose.
If you’re using a different version of OpenSSL from that which the script is built for, you’ll need to modify the OPENSSL_VERSION= line in the script to match.
NOTE: Some servers have not had their SSL updated (to protect against Logjam attacks <link>), and connecting to them using later versions of OpenSSL may fail. e.g. the SSL on Embarcadero’s news server (this may change after this article is published). In order to successfully connect to these I used version 1.0.2a of OpenSSL. The latest version (1.0.2g at time of writing) may work on other servers.
Next, modify the Makefile.shared file that’s in the root of the folder which contains the OpenSSL source.
The line that needs to be modified looks like this:
SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \[/sourcecode]
Replace $(INSTALLTOP)/$(LIBDIR)/ with @executable_path, so that the line looks like this:
SHAREDFLAGS="$$SHAREDFLAGS -install_name @executable_path/$$SHLIB$(SHLIB_EXT)"; \[/sourcecode]
The @executable_path value means that the system will expect the dylib to be in the same location as the executable. We’ll see why this is important when deployment is covered.
Next, the script needs to have its properties changed so that it can be executed. Using the Terminal app,
change folder to the one created earlier to put the script in, e.g:
where <username> is the username you log into your Mac with, then use the following command:
chmod +x openssl-build-shared.sh
..and execute the script:
This will take about 5-10 minutes depending on your machine. When it has finished successfully, the resulting dylibs will be in the lib/iOS folder, which is off of the folder where the script is located.
If necessary, copy/move these files to a location where they can be included in your Delphi project to be deployed with your app. In my setup, I have a folder shared to a VirtualBox VM that has Delphi 10 Seattle installed, so I can share files between my Mac and the VM.
In your Delphi project, bring up the deployment manager. Click the Add files button
Navigate to the folder containing the dylibs, select both of them and click OK
The remote path (.\) is the same folder as the application, so this does not need to be changed (same as the @executable_path in the makefile, described earlier)
In your code, somewhere before it attempts to make an SSL connection you will need to set the OpenSSL search path for Indy, when compiling for the iOS simulator:
This sets the path to the dylibs as the executable directory.
I hope this has been of some use. It was certainly satisfying for me to finally make this work, and I wanted to share it with others.