-
Notifications
You must be signed in to change notification settings - Fork 305
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
Problem with verify_peer: false #541
Comments
Both This means that if Perhaps |
They both evaluate to 'falsey', but they don't explicitly evaluate to 'false' (this is in Ruby 2.4.1.p111). Again, irb(main):030:0> false || nil However, in the method, the check is done with nil?, which evaluates to true in one case and false in the other, i.e. irb(main):032:0> (false || nil).nil? So if both verify_ssl and verify_peer are falsey, then the value of opts[:verify] will determine what happens, and the result is different depending on whether it is unset (nil) or explicitly set to false. Which doesn't seem like what one would expect. (I expect to just have to set verify_peer to false.) I'm not familiar with the code really, but why is this potential resetting of opts[:verify_peer] even needed? It looks like @verify_peer is set correctly later in the method except for the fact that opts[:verify_peer] may have been modified already. |
What one would expect depends on how many keys one is aware of. As of 2.9.0 there is one more key. We can lower its priority or we can declare that things work as expected (for 2.9.0). There was a version bump for a reason. |
That's fine too, but the docs don't really reflect that if you want to skip peer verification that setting verify_peer: false isn't enough to do so. |
I'm fine with a PR that gives |
What is the intent of that bit of code? Is it to set a default if none of those three keys are specified? If so then that still doesn't do it. I'd think you'd want:
|
AFAICT it simply sets the default. |
|
Going from Bunny 2.7.0 to 2.9.1 I found that verify_peer: false was no longer being respected when in my configuration options for a connection. I think I have a handle on the problem.
From an irb session with 2.9.1:
Note that in @opts for the transport, :verify_peer is now true.
The problem appears to be in transport.rb in the prepare_tls_context method, in this section:
It's best illustrated by another little irb snippet:
I confirmed that if I also pass verify: false then things are back to normal. It's unclear to me what the section of code referenced above is really supposed to be doing, as the verify_peer instance variable is set more robustly later in the same method.
The text was updated successfully, but these errors were encountered: