-
Notifications
You must be signed in to change notification settings - Fork 5
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
Is this usable? #5
Comments
Humm, I've worked around another issue, and finally managed to establish proper connectivity. My client is using However, this means that ruby-tls currently only works with I've tried to patch the lib and attach other openssl functions like
Does this make sense? This lib should be FFI'ing into the same libssl object file that my ruby's openssl is, right? Which is, in this case, ruby 2.4, which enables TLS 1-up-to-1.2 . |
It doesn't use the ruby libssl and uses the systems libssl - which is probably where the issue is being introduced - we needed features before they were available in Ruby and it is used for SSL connections in https://github.com/cotag/libuv |
Indeed. I just confirmed that in my MacOS Sierra, the
However, this is one of 5 possible ssl lib files (in my system, I have I don't know what's the best way to approach this, as I'm afraid that in most cases, the default lib file will be an old version of ssl (in the mac OS, waaaay old), and this disables a lot of the benefits I was hoping to get, like TLS 1.2 / ALPN support, which is necessary for http2. |
It'll pick the first library it discovers - this hasn't been an issue for us as we do most of our work in docker containers - I think I used homebrew to install a new version of openssl for development work. Ruby's version of OpenSSL isn't distributed as a dynamic link library so we can't access the methods we need without using a 3rd party lib. One option would be to add openssl as a subproject to this project and compile it at GEM install time then link to the local copy of openssl - which would keep versions tightly coupled. I've done something similar for the libuv gem we maintain |
I've also installed a new version of openssl using brew, and link it. But any program will compile with the system openssl by default. I've compiled latest cURL's against this new version, but had to specify the path myself. Unfortunately I can't specify the path using a 3rd-party gem. Your last solution seems the one where you can control what you expect. I've seen that only |
I've forked and am running a local version of this lib, and added this: ffi_lib ['ssl.39', 'ssl.35', 'ssl'] attached the missing symbols and reran my tests. And it all just works. A notable change is that I get a protocol on handshake completion ("h2") instead of nothing (which is what happens if I run my tests in SSLv23 mode, for lack of ALPN support). I'll see if I can create a client with this lib to demonstrate what happens locally, and also to get tests passing in jruby (which was my main point to use this lib, as I'll see if I can get a patch. |
btw, what are you using for verifying certs against a chain? I see that this should be verified in the |
Awesome! |
Thx for the link, but I'm afraid that it doesn't help me, at least what concerns the actual job of verifying the cert. My question would be more "how to do this in plain Ruby?", as ruby's "openssl" uses an openssl specific API for that apparently (it even uses the system default ca dir if none is provided). So the question would be: does it bring value to show how to do this in plain ruby, or could this gem provide the same solution as openssl, i.e. verify the server certificate against the local provided ca bundle? |
Looks like we could just use the ruby OpenSSL code: https://github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb#L261 OpenSSL::SSL.verify_certificate_identity(cert, hostname) |
Isn't that to verify the hostname (SNI)? Not that I have anything against it being done. I meant more this snippet: https://github.com/ruby/openssl/blob/e72d960db2623b21ee001b5a7b9d9e6ff55bdf94/ext/openssl/ossl_ssl.c#L877-L892 If passed a ca file bundle and |
That is the same as what this library does when you set the Then the code to perform a standard verification is https://github.com/ruby/openssl/blob/master/lib/openssl/ssl.rb#L261 The blob you've referenced above is where they are setting up the callbacks |
I have a test with The only thing that this If I do the same using OpenSSL, I get a: ctx.ca_file_path = 'path/to/ca_file'
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
Shouldn't this gem be doing the same and handle verification? |
Ahh yeah, you could be right. Based on this example https://wiki.openssl.org/index.php/Manual:SSL_CTX_set_verify(3) I still think the verification has to happen in that callback.. Maybe we just do it for the user? Or I could be looking at the wrong thing again and totally misunderstanding what we should be verifying |
I'd say so. I'm just struggling with finding where |
I've been looking for an alternative for 'openssl', that plays well with jruby. This seemed to be it, as it supports ALPN as well. However, I'm struggling to make it work. I'm testing against an openssl-enabled client, And it fails when the tls server starts and sends the first message:
The thing I saw was that there is (currently) no way to set the version.
Do you have any working example with sockets/network protocols?
The text was updated successfully, but these errors were encountered: