-
Notifications
You must be signed in to change notification settings - Fork 984
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
Do not use :insecure option by default in Patron #691
Do not use :insecure option by default in Patron #691
Conversation
The session.insecure option is set to true by default. This disables the ssl verification of the host and, according to the Patron documentation, one should "think twice before using this option". See also http://www.rubydoc.info/gems/patron/0.8.0/Patron%2FSession%3Ainsecure
I came across this default setting when I tried to use Patron with a proxy (and fighting with SSL cert verification issues). As far as I'm aware, I guess the insecure option shouldn't be enabled by default. Unfortunately it was added in 2012 already: Therefore I'm not sure if reverting this commit would break some production apps. But from a security standpoint, it should be disabled, I guess. 🙈 |
😢 The CI tests are failing while my local tests went through. It seems the CI server has some CA certs missing for the ssl certificates issued for example.com. Still, I think just disabling SSL verification by default is a rather bad idea. I'm not very familiar with Travis. Probably that could be solved by adding something like that to travis.yml (see travis-ci/travis-ci#6142)?
|
Hi @stayhero and thanks for the Issue report. The only other thing that scares me is the backward-compatibility, but we'll figure that out later on. Let's get tests green again first! |
The patron adapter didn't support the ssl: {verify: false} option nor the ca_file. This was also the reason why the tests running on the local server failed. The adapter now supports both options. As Patron does not allow setting the session.insecure option to true and supply a ca_file at the same time, we need to only set either the insecure or the session.cacert option.
@iMacTia It seems the test were failing because the ca_file option was not supported by the adapter. Because the integration tests itself supply a valid certificate for the localhost server. The tests also disable the ssl verification, but this was not supported by the Patron adapter as well. Now the tests should work and the insecure option is supported properly. Regarding the backwards-compatibility: I think most users will appreciate the security improvement, otherwise using the Faraday option |
I used the !! operator to set session.insecure before I introduced the if/else condition (because Patron does not like receiving a cacert and insecure=true option at the same time).
I see, the adapter was not supporting the However, does that mean that
Is my understanding correct? |
I had the same thoughts but Patron raises an error if the cacert is set and the verification is deactivated (i. e. insecure is set to true). Hence we are not allowed to set a cacert and disable ssl verification. |
To make it clear: you don't need to set cacert. I just optimized the additional if away because it should not matter if you set session.cacert = nil or set it not at all. Surely you could modify the line to something like
|
I get your point now. |
The session.insecure option is set to true by default. This disables
the ssl verification of the host and, according to the Patron
documentation, one should "think twice before using this option".
See also
http://www.rubydoc.info/gems/patron/0.8.0/Patron%2FSession%3Ainsecure