Missing SDK Files for Apple LibreSSL

4 months ago 28

MacOS ships with a modified version of LibreSSL that uses the MacOS keychain as the CA trust store. However Apple did not provide the required SDK files to link to this library, so this repo has the missing headers and tbd files, taken from the upstream open source repositories.

You can use these files to build a newer version of curl, with the same configuration as curl included with MacOS, i.e. have LibreSSL use the keychain trust store.

Either build your project with -I and -L flags or point autoconf to the root dir.

If you want to copy what apple employees seems to do you need to clone this repo into $(xcrun --show-sdk-path)/usr/local/libressl.

As also noted by Apple, makes ure to not have other libs (e.g. homebrew) on your PATH or PKG_CONFIG_PATH. Here is a script to build curl from source:

PATH="/bin:/usr/bin/:/usr/local/bin:/usr/sbin" git clone https://github.com/jeroen/apple-libressl-sdk SDKFILES="$PWD/apple-libressl-sdk" curl -OL https://curl.se/download/curl-8.13.0.tar.gz tar xf curl-8.13.0.tar.gz cd curl-8.13.0 ./configure --enable-threaded-resolver --with-gssapi --with-ssl=$SDKFILES --with-nghttp2=$SDKFILES --with-secure-transport --without-libpsl make # make install

To confirm that it worked, look at otool -L output to see if it libcurl indeed is linked to openssl and nghttp from /usr/lib:

# From the build dir above otool -L ./lib/.libs/libcurl.dylib # /usr/local/lib/libcurl.4.dylib (compatibility version 13.0.0, current version 13.0.0) # /usr/lib/libapple_nghttp2.dylib (compatibility version 1.0.0, current version 1.55.1) # /usr/lib/libssl.48.dylib (compatibility version 49.0.0, current version 49.2.0) # /usr/lib/libcrypto.46.dylib (compatibility version 47.0.0, current version 47.2.0) # ...

The headers were simply downloaded from upstream sources:

The .tbd (text-based stub) files were generated by first building LibreSSL 3.3.6 from source and then using tapi stubify on the shared libraries:

PATH="/Library/Developer/CommandLineTools/usr/bin/:$PATH" tapi stubify --filetype=tbd-v4 libcrypto.dylib tapi stubify --filetype=tbd-v4 libssl.dylib

And afterwards manually the install-name and targets were manually modified with a text editor.

Read Entire Article