-
Notifications
You must be signed in to change notification settings - Fork 31
Support OpenSSL 1.1.0 #34
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
Comments
So I tried the following patch: diff --git a/lib/OpenSSL.pm6 b/lib/OpenSSL.pm6
index 7c3d96c..3840f8d 100644
--- a/lib/OpenSSL.pm6
+++ b/lib/OpenSSL.pm6
@@ -35,8 +35,14 @@ method new(Bool :$client = False, ProtocolVersion :$version = -1) {
# can't find the required libeay32.dll anywhere in the path, and so fails to load the dll
OpenSSL::EVP::EVP_aes_128_cbc();
- OpenSSL::SSL::SSL_library_init();
- OpenSSL::SSL::SSL_load_error_strings();
+ try {
+ CATCH {
+ # The mask is OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS.
+ default { OpenSSL::SSL::OPENSSL_init_ssl(0x00300000, Nil); }
+ }
+ OpenSSL::SSL::SSL_library_init();
+ OpenSSL::SSL::SSL_load_error_strings();
+ }
my $method;
given $version {
diff --git a/lib/OpenSSL/SSL.pm6 b/lib/OpenSSL/SSL.pm6
index b3c3e79..4faf6a9 100644
--- a/lib/OpenSSL/SSL.pm6
+++ b/lib/OpenSSL/SSL.pm6
@@ -37,6 +37,7 @@ class SSL is repr('CStruct') {
}
our sub SSL_library_init() is native(&ssl-lib) { ... }
+our sub OPENSSL_init_ssl(uint64, OpaquePointer) is native(&ssl-lib) { ... }
our sub SSL_load_error_strings() is native(&ssl-lib) { ... }
our sub SSL_new(OpenSSL::Ctx::SSL_CTX) returns SSL is native(&ssl-lib) { ... } but, as expected, this is not enough, it now crashes later in
I'm afraid I have to abandon now, all I wanted was to write a small script making parallel HTTPS requests and unfortunately this just seems to be impossible currently :-( |
Thanks to vadz for doing most of the legwork. I have had success using the following. The only change was the values used in the call to OPENSSL_init_ssl: diff --git a/lib/OpenSSL.pm6 b/lib/OpenSSL.pm6
index 7c3d96c..d4d401e 100644
--- a/lib/OpenSSL.pm6
+++ b/lib/OpenSSL.pm6
@@ -34,9 +34,14 @@ method new(Bool :$client = False, ProtocolVersion :$version = -1) {
# if we're using our bundled .dll files, and we try to load ssleay32.dll first, LoadLibrary
# can't find the required libeay32.dll anywhere in the path, and so fails to load the dll
OpenSSL::EVP::EVP_aes_128_cbc();
-
- OpenSSL::SSL::SSL_library_init();
- OpenSSL::SSL::SSL_load_error_strings();
+
+ try {
+ CATCH {
+ default { OpenSSL::SSL::OPENSSL_init_ssl(0, OpaquePointer); }
+ }
+ OpenSSL::SSL::SSL_library_init();
+ OpenSSL::SSL::SSL_load_error_strings();
+ }
my $method;
given $version {
@@ -185,7 +190,7 @@ multi method write(Blob $b) {
my $ret;
loop {
- $ret = OpenSSL::SSL::SSL_write($!ssl, $b, $n);
+ $ret = OpenSSL::SSL::SSL_write($.ssl, $b, $n);
my $e = $.handle-error($ret);
last unless $e > 0;
diff --git a/lib/OpenSSL/SSL.pm6 b/lib/OpenSSL/SSL.pm6
index b3c3e79..4faf6a9 100644
--- a/lib/OpenSSL/SSL.pm6
+++ b/lib/OpenSSL/SSL.pm6
@@ -37,6 +37,7 @@ class SSL is repr('CStruct') {
}
our sub SSL_library_init() is native(&ssl-lib) { ... }
+our sub OPENSSL_init_ssl(uint64, OpaquePointer) is native(&ssl-lib) { ... }
our sub SSL_load_error_strings() is native(&ssl-lib) { ... }
our sub SSL_new(OpenSSL::Ctx::SSL_CTX) returns SSL is native(&ssl-lib) { ... } |
I've added this as a PR for convenience. |
Thanks @Xliff! I can confirm that not loading strings indeed avoids the crash (I don't know OpenSSL API, so I have no idea if it has any drawbacks -- perhaps it means we're not going to get user-readable error messages?). I could now install this module and use v6;
use HTTP::UserAgent;
use HTTP::Request;
use URI;
my Str @urls = "https://www.google.com/",
"https://www.yahoo.com/",
"https://www.microsoft.com/";
my Promise @p = (for @urls -> $url {
start {
say "Making request to $url...";
my URI $uri .= new($url);
my HTTP::UserAgent $ua .= new;
my HTTP::Response $res = $ua.request(HTTP::Request.new(GET => $uri));
say "Got response from $url with status code: {$res.code}";
"URL: $url (Code: {$res.code})";
}
});
await @p; |
Odd. I don't get SEGVs on my end, but I do get that error I attempted to At least I have a use case for it, now. Can you verify this result on your end? $ perl6 -I projects/openssl/lib -e 'use HTTP::UserAgent; use Thanks!
On Fri, Nov 18, 2016 at 8:04 AM, VZ notifications@github.com wrote:
|
Yes, I'm getting the same thing (with different hashes, of course). However I don't get it if I use |
Nevermind. I forgot the .new when I did "HTTP::UserAgent.get" /o\ Nevertheless, when I now run the script, I am getting:
Which is weird, since I am not getting that in my larger script. |
I had to use an explicit |
Spoke too soon. Making a simple change (well, reverting rather): use v6;
use HTTP::UserAgent;
use HTTP::Request;
use URI;
my Str @urls = "https://www.google.com",
"https://www.yahoo.com",
"https://www.microsoft.com";
my Promise @p = (for @urls -> $url {
start {
say "Making request to $url...";
my $ua = HTTP::UserAgent.new;
my $res = $ua.get($url);
say "Got response from $url with status code: {$res.code}";
"URL: $url (Code: {$res.code})";
}
});
await @p; Made it go kablewy!
However my original version (slightly changed from yours): use v6;
use HTTP::UserAgent;
use HTTP::Request;
use URI;
my Str @urls = "https://www.google.com",
"https://www.yahoo.com",
"https://www.microsoft.com";
my Promise @p = (for @urls -> $url {
start {
say "Making request to $url...";
my $res = HTTP::UserAgent.new.get($url);
say "Got response from $url with status code: {$res.code}";
"URL: $url (Code: {$res.code})";
}
});
await @p; Didn't crash and caused the weird error message in my previous post! On your "-I issue", it sounds like you might need to force a recomp. You may want to consider removing ~/.perl6/.precomp -- but that's the Nuclear Option! |
Yes, the heap corruption looks to be the same one I'm seeing (and the "nice" thing is that I'm under amd64 and you're under i386, so it's not arch-specific). Looking at OpenSSL docs it seems that an extra effort is needed to use it from multiple threads, so I guess it's time to open another issue for it... |
More like .get being invoked from a container. It's the only thing I
can think of.
|
@Xliff could you possibly reproduce the missing IO::Socket::SSL not installed error but with RAKUDO_MODULE_DEBUG=1 and gist the output? |
Sure thing: https://gist.github.com/Xliff/bd157adb0fb484ea50caa4f5c5aa683b On Fri, Nov 18, 2016 at 12:29 PM, Nick Logan notifications@github.com
|
This doesn't seem to work with OpenSSL 1.1.0, as included in Debian Sid, right now: the tests fail when installing it with error messages similar to this:
apparently because
SSL_library_init()
has been replaced withOPENSSL_ssl_init()
now (at least the former function is not in my/usr/lib/x86_64-linux-gnu/libssl.so.1.1
, but the latter is). I am probably going to try changing a local version to use the new function in desperation (because as it stands, HTTP::UserAgent is just completely unusable with HTTPS for me because of #1 under Jessie and this one in Sid.), but I guess this is not going to be enough as there are probably other API changes in 1.1.The text was updated successfully, but these errors were encountered: