-
Notifications
You must be signed in to change notification settings - Fork 28
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
Net::HTTP adapter trusts all system root CAs when a ca_file is specified #14
Comments
Thanks for the nice report. I get the problem; however, I have the feeling that people right now are using How about that you can choose to disable the default cert store if you deliberately want to do CA pinning? E.g. Faraday.new('...', ssl: { ca_file: 'ca.pem', cert_store: false }) Would that satisfy your needs? We would need to investigate how current HTTP libs (including net/http) behave in this regard: are we able to turn off the default system certs by passing no cert store object? If you have time and will to test this, it would be great. |
Hey @mislav thanks for the response. One immediate remediation I am currently using is to set the
Or to just use a cert_store:
However, the only adapters that currently support
The I'll take a little time to see how the other HTTP libs behave when just a |
Have tested situation on CRuby 2.7 & 3.0 (both with OpenSSL's 1.1.1) with http = Net::HTTP.new('example.com', 443) # Certificate https://crt.sh/?id=3704614715
http.use_ssl = true
http.start
|
Thanks for jumping in on this @aleksandrs-ledovskis, would you please clarify out of the 4 points above which ones are working as expected and which ones are not? |
The examples are from |
Problem
Faraday always trusts the OpenSSL system root CAs, even when a
:ca_file
or a:ca_path
are specified, eg to implement CA pinning, or to reduce the number of trusted certificates.Example
Expected behavior:
An error about server certificate certificate validation, because the website's certificate does not match the
:ca_file
Root Cause:
Within the
net_http
adapter,ssl_cert_store
will create a certificate store that includes the OpenSSL system root CAs if:cert_store
is not specified:https://github.com/lostisland/faraday/blob/master/lib/faraday/adapter/net_http.rb#L105
I would think that Faraday should only set a default
:cert_store
if there is no:ca_file
, no:ca_path
, and no:cert_store
specified.The text was updated successfully, but these errors were encountered: