Skip to content

Fix swapped libssl/libcrypto names on macOS (SSL cannot initialise) - #196

Merged
winddriver merged 1 commit into
winddriver:masterfrom
Vizit0r:fix/openssl-macos-lib-names
Aug 5, 2026
Merged

Fix swapped libssl/libcrypto names on macOS (SSL cannot initialise)#196
winddriver merged 1 commit into
winddriver:masterfrom
Vizit0r:fix/openssl-macos-lib-names

Conversation

@Vizit0r

@Vizit0r Vizit0r commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

TSSLTools.LoadSslLibs builds the macOS candidate list for libcrypto out of 'libssl.dylib', and the list for libssl out of 'libcrypto.dylib' — the two are swapped.

The consequence is not cosmetic: FSslLibHandle ends up pointing at libcrypto, and the very first lookup off it

@OPENSSL_init_ssl := GetSslLibProc(FSslLibHandle, 'OPENSSL_init_ssl');

raises ESslInvalidProc (GetSslLibProc raises when the symbol is missing, and libcrypto does not export any SSL_*). So SSL cannot initialise on macOS whenever OpenSSL is loaded dynamically — which is everywhere except iOS/Android, since __SSL_STATIC__ is only defined for those two and the whole body of LoadSslLibs is under {$IFNDEF __SSL_STATIC__}.

Changes

  1. Swap the two macOS lists.
  2. Add the versioned names, mirroring what the LINUX branch already does. OpenSSL 3 installs libcrypto.3.dylib / libssl.3.dylib; the unversioned symlinks are not always present.
  3. Small copy/paste fix in the same routine — the static-name branch for LSslLibs tests LIBCRYPTO_NAME but assigns LIBSSL_NAME:
    if (FLibSSL <> '') then
      LSslLibs := [FLibSSL]
-   else if (LIBCRYPTO_NAME <> '') then
+   else if (LIBSSL_NAME <> '') then
      LSslLibs := [LIBSSL_NAME]

This one is currently unreachable (both consts are '' in dynamic builds, and the routine is compiled out in static ones), so it is just cleanup — happy to drop it from this PR if you would rather keep it focused.

Checked

Compiles clean on Win64 (Delphi 37.0) via Net.CrossWebSocketClient.pas, which pulls in Net.OpenSSL — no new warnings or hints.

TSSLTools.LoadSslLibs builds the macOS candidate list for libcrypto out of
'libssl.dylib' and the list for libssl out of 'libcrypto.dylib'. The libssl
handle therefore points at libcrypto and the first
GetSslLibProc(FSslLibHandle, 'OPENSSL_init_ssl') raises ESslInvalidProc, so
SSL cannot initialise on macOS whenever OpenSSL is loaded dynamically -- that
is everywhere except iOS/Android, which take the __SSL_STATIC__ path.

Swap the two lists and add the versioned names, mirroring what the LINUX
branch already does: OpenSSL 3 installs libcrypto.3.dylib / libssl.3.dylib
and the unversioned symlinks are not always present.

Also fix a copy/paste in the same routine: the static-name branch for
LSslLibs tests LIBCRYPTO_NAME but assigns LIBSSL_NAME.
@winddriver
winddriver merged commit a93ac8d into winddriver:master Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants