Skip to content
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

SSL_CERT_FILE environment variable is not honoured #369

Open
mikz opened this issue Jun 27, 2017 · 6 comments · May be fixed by #386 or #402
Open

SSL_CERT_FILE environment variable is not honoured #369

mikz opened this issue Jun 27, 2017 · 6 comments · May be fixed by #386 or #402

Comments

@mikz
Copy link

mikz commented Jun 27, 2017

OpenSSL says SSL_CERT_FILE and SSL_CERT_DIR environment variables can be used to set default location for certificate fails. HTTPClient ignores this setting.

Net::HTTP respects that setting.

$ ruby -rnet/http -e "Net::HTTP.get URI('https://example.com/')"
$ echo $?
0
$ SSL_CERT_FILE=/etc/foo ruby -rnet/http -e "Net::HTTP.get URI('https://example.com/')"
ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError)

HTTPClient does not.

$ ruby -rhttpclient -e "HTTPClient.new.get_content('https://example.com/')"
$ echo $?
0
$ SSL_CERT_FILE=/etc/foo ruby -rhttpclient -e "HTTPClient.new.get_content('https://example.com/')"
$ echo $?
0

There is no system-wide way of configuring HTTPClient to use default system store and has to be initialised on per instance basis as described in #335.

Also, the bundle cacert.pem is almost 2 years old missing several important updates.

I think HTTPClient should not default to own bundled CA certificates if system provides that. That might be broken on Windows, but this breaks it on every other UNIX platform.

@mikz
Copy link
Author

mikz commented Jun 27, 2017

Preliminary patch mikz@3298246

@redbaron
Copy link

been hit by this too, any chance it can be reviewed?

@redbaron
Copy link

In case somebody spent last 3 hours tracing SSL errors down to this issue, here is workaround which works for me:

for x in ./lib/ruby/gems/*/gems/**/cacert.pem; do rm $x; ln -s /etc/ssl/certs/ca-certificates.crt $x; done

@mikz
Copy link
Author

mikz commented Nov 29, 2017

We are running with master...mikz:ssl-env-cert and it works just fine. And set the SSL_CERT_DIR or SSL_CERT_FILE env variable.

That is just a terrible workaround and would be way better for httpclient to use OpenSSL cert store it was compiled with.

@mikz
Copy link
Author

mikz commented Feb 27, 2018

Fixed by #386

@febeling febeling linked a pull request Dec 28, 2018 that will close this issue
jgoerz pushed a commit to jgoerz/rack-oauth2 that referenced this issue Jan 16, 2019
@vfazio
Copy link

vfazio commented Jul 15, 2019

any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants