Skip to content

Commit c0d1843

Browse files
committed
Ignore a libcrypto.dylib with the wrong architecture
If you install Homebrew with arch -x86_64, you get a /usr/local/lib/libcrypto.dylib that the system Python can't load. We should ignore the resulting error and proceed without that library (which does not ship with the OS any more). The error looks like: OSError: cannot load library '/usr/local/lib/libcrypto.dylib': dlopen(/usr/local/lib/libcrypto.dylib, 0x0002): tried: '/usr/local/lib/libcrypto.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libcrypto.dylib' (no such file), '/usr/local/lib/libcrypto.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/usr/local/Cellar/openssl@3/3.3.1/lib/libcrypto.3.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/openssl@3/3.3.1/lib/libcrypto.3.dylib' (no such file), '/usr/local/Cellar/openssl@3/3.3.1/lib/libcrypto.3.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
1 parent 1547f53 commit c0d1843

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

oscrypto/_mac/util.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ def pkcs12_kdf(hash_algorithm, password, salt, iterations, key_length, id_):
348348

349349
return bytes_from_buffer(output_buffer)
350350

351-
except (LibraryNotFoundError):
351+
except (LibraryNotFoundError, OSError):
352+
# OpenSSL no longer ships with macOS. If you install Homebrew with arch -x86_64, you end
353+
# up with a /usr/local/lib/libcrypto.dylib that will not work with an arm64 Python, and
354+
# will fail to load with an OSError. In that case, we should still fall back as if it
355+
# were missing.
352356

353357
from .._pkcs12 import pkcs12_kdf

0 commit comments

Comments
 (0)