Use arrays for potential OpenSSL lib filenames

This should fix SSL loading on macOS while allowing for easy additions
on so-name bumps on any platform.
This commit is contained in:
JR 2022-04-20 15:46:21 +02:00
parent 79b630e547
commit 628e02c989
1 changed files with 49 additions and 22 deletions

71
http2.d
View File

@ -3252,33 +3252,60 @@ version(use_openssl) {
return;
synchronized(loadSslMutex) {
version(OSX) {
// newest box
ossllib_handle = dlopen("libssl.1.1.dylib", RTLD_NOW);
// other boxes
if(ossllib_handle is null)
ossllib_handle = dlopen("libssl.dylib", RTLD_NOW);
// old ones like my laptop test
if(ossllib_handle is null)
ossllib_handle = dlopen("/usr/local/opt/openssl/lib/libssl.1.0.0.dylib", RTLD_NOW);
version(Posix) {
version(OSX) {
static immutable string[] ossllibs = [
"libssl.46.dylib",
"libssl.44.dylib",
"libssl.43.dylib",
"libssl.35.dylib",
"libssl.1.1.dylib",
"/usr/local/opt/openssl/lib/libssl.1.0.0.dylib",
"libssl.dylib",
];
} else {
static immutable string[] ossllibs = [
"libssl.so.1.1",
"libssl.so.1.0.2",
"libssl.so.1.0.1",
"libssl.so.1.0.0",
"libssl.so",
];
}
} else version(Posix) {
ossllib_handle = dlopen("libssl.so.1.1", RTLD_NOW);
if(ossllib_handle is null)
ossllib_handle = dlopen("libssl.so", RTLD_NOW);
foreach(lib; ossllibs) {
ossllib_handle = dlopen(lib.ptr, RTLD_NOW);
if(ossllib_handle !is null) break;
}
} else version(Windows) {
version(X86_64)
version(X86_64) {
ossllib_handle = LoadLibraryW("libssl-1_1-x64.dll"w.ptr);
if(ossllib_handle is null)
ossllib_handle = LoadLibraryW("libssl32.dll"w.ptr);
version(X86_64)
oeaylib_handle = LoadLibraryW("libcrypto-1_1-x64.dll"w.ptr);
if(oeaylib_handle is null)
oeaylib_handle = LoadLibraryW("libeay32.dll"w.ptr);
} else {
static immutable wstring[] ossllibs = [
"libssl-1_1.dll"w,
"libssl32.dll"w,
];
if(ossllib_handle is null) {
ossllib_handle = LoadLibraryW("ssleay32.dll"w.ptr);
oeaylib_handle = ossllib_handle;
foreach(lib; ossllibs) {
ossllib_handle = LoadLibraryW(lib.ptr);
if(ossllib_handle !is null) break;
}
static immutable wstring[] eaylibs = [
"libcrypto-1_1.dll"w,
"libeay32.dll",
];
foreach(lib; eaylibs) {
oeaylib_handle = LoadLibraryW(lib.ptr);
if (oeaylib_handle !is null) break;
}
if(ossllib_handle is null) {
ossllib_handle = LoadLibraryW("ssleay32.dll"w.ptr);
oeaylib_handle = ossllib_handle;
}
}
}