-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link error with new openssl 1.1.0e #45
Comments
Hello, |
Hello @zorael |
Downgrading is not really a solution. Ideally, Requests would be compatible with the OpenSSL 1.1 API, as it will need to do that sooner or later anyway. From the OpenSSL documentation:
The other API changes seem fairly easy to wrap in a compatible way too. |
Telling dlang-requests to link to the old libraries explicitly does work: diff --git a/dub.json b/dub.json
index 3ae8ef3..4d6e259 100644
--- a/dub.json
+++ b/dub.json
@@ -9,7 +9,7 @@
"configurations": [
{
"name": "std",
- "libs-posix": ["ssl", "crypto"],
+ "libs-posix": [":libssl.so.1.0.0", ":libcrypto.so.1.0.0"],
"libs-windows": ["libssl32", "libeay32"]
},
{ |
This also affects Debian 9 (stable). |
Ok, will rise priority for this problem. |
|
A hack would be to use |
Looks like OpenSSL does define symbols for each version, so you can check whether you can find a symbol called |
Hello, Current plan is to try to use preBuildCommand to detect libssl version and then use it somehow to manage I spent several days looking for portable way (targets are Linux, OSX, Windows, FreeBSD) to find current version of openssl library. I would like to avoid dependencies outside of D as much as possible - that is I'd like to avoid calling command line tools like 'openssl version -a', nm, objdump, readelf, etc, and compiling C sources. To find which symbols are available we can use dlopen("libssl.so") and it will work for all unix-like OS's, but I do not know anything about Windows. @CounterPillow @wilzbach what do you think? |
Sounds good to me. TBH I only really care about Linux ;-)
Same here, maybe @CyberShadow knows a good solution for Windows? Btw maybe the DerelictLoader SharedLibLoader will work? |
Sorry, my use of dub is entirely reluctant to ease use of my code by people who do use it, don't think I can help much with that. As for |
The is opinion that OpenSSL is suxx http://queue.acm.org/detail.cfm?id=2602816 and error prone. |
@bubnenkoff please keep discussion here constructive |
Hello, Right now it looks like import std.stdio;
import std.string;
import std.format;
import std.typecons;
import core.stdc.stdlib;
import core.sys.posix.dlfcn;
version(Windows) {
import core.sys.windows.windows;
alias DLSYM = GetProcAddress;
} else {
alias DLSYM = dlsym;
}
static OpenSSL openssl;
static this() {
openssl.loadLib();
openssl.initSSL();
}
struct OpenSSL {
alias Version = Tuple!(int, "major", int, "minor");
Version _ver;
void* _libssl;
void* _libcrypto;
Version reportVersion() const @nogc nothrow pure {
return _ver;
};
void OpenSSL_version_detect() {
long function() OpenSSL_version_num = cast(long function())DLSYM(_libssl, "OpenSSL_version_num");
if ( OpenSSL_version_num ) {
auto v = OpenSSL_version_num();
_ver = Version((v>>>20) & 0xff, (v>>>28) & 0xff);
return;
}
_ver = Version(1, 0);
}
void init1_0() {
extern (C) int function() SSL_library_init = cast(int function())DLSYM(_libssl, "SSL_library_init");
extern (C) void function() OpenSSL_add_all_ciphers = cast(void function())DLSYM(_libcrypto, "OpenSSL_add_all_ciphers");
extern (C) void function() OpenSSL_add_all_digests = cast(void function())DLSYM(_libcrypto, "OpenSSL_add_all_digests");
extern (C) void function() SSL_load_error_strings = cast(void function())DLSYM(_libssl, "SSL_load_error_strings");
SSL_library_init();
OpenSSL_add_all_ciphers();
OpenSSL_add_all_digests();
SSL_load_error_strings();
}
void init1_1() {
/**
Standard initialisation options
#define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L
# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L
# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L
# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L
**/
enum OPENSSL_INIT_LOAD_SSL_STRINGS = 0x00200000L;
enum OPENSSL_INIT_LOAD_CRYPTO_STRINGS = 0x00000002L;
enum OPENSSL_INIT_ADD_ALL_CIPHERS = 0x00000004L;
enum OPENSSL_INIT_ADD_ALL_DIGESTS = 0x00000008L;
extern (C) int function(ulong, void*) OPENSSL_init_ssl = cast(int function(ulong, void*))DLSYM(_libssl, "OPENSSL_init_ssl");
extern (C) int function(ulong, void*) OPENSSL_init_crypto = cast(int function(ulong, void*))DLSYM(_libcrypto, "OPENSSL_init_crypto");
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, null);
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, null);
}
void initSSL() {
void delegate()[Version] init_matrix;
init_matrix[Version(1,0)] = &init1_0;
init_matrix[Version(1,1)] = &init1_1;
auto init = init_matrix.get(_ver, null);
if ( init is null ) {
throw new Exception("loading openssl: unknown version for init");
}
init();
}
void loadLib() {
if ( _libssl !is null ) {
return;
}
version(OSX) {
_libssl = dlopen("libssl.dylib", RTLD_LAZY);
_libcrypto = dlopen("libcrypto.dylib", RTLD_LAZY);
} else
version(linux) {
_libssl = dlopen("libssl.so", RTLD_LAZY);
_libcrypto = dlopen("libcrypto.so", RTLD_LAZY);
} else
version(Windows) {
_libssl = LoadLibrary("libssl32.dll");
_libcrypto = LoadLibrary("libeay32.dll");
} else {
throw new Exception("loading openssl: unsupported system");
}
if ( _libssl is null ) {
version(Windows) {
throw new Exception("loading libssl: error %d".format(GetLastError()));
} else {
throw new Exception("loading openssl: %s",format(fromStringz(dlerror())));
}
}
if ( _libcrypto is null ) {
version(Windows) {
throw new Exception("loading libcrypto: error %d".format(GetLastError()));
} else {
throw new Exception("loading libcrypto: %s",format(fromStringz(dlerror())));
}
}
OpenSSL_version_detect();
}
}
int main() {
auto v = openssl.reportVersion();
writefln("openSSL v.%s.%s", v.major, v.minor);
return 0;
}
|
Hello, I pushed to github what was done for openssl 1.0/1.1 linking. Code tested for openssl 1.0 on Linux, OSX, Windows7, and openssl 1.1 tested on debian "stretch". Please, check and report on any issues. Thanks! PS. I will make new release in few days, so anybody can try it. |
Hello, @zorael |
Arch linux recently updated their
openssl
package to1.1.0e
, and with it dlang-requests no longer links.There now exists an
openssl-1.0
package with the old library (.so-versioned), but installing it doesn't seem to be enough.The text was updated successfully, but these errors were encountered: