Sitelet https://github.com/jruby/jruby/issues/2249
Skip to content

Improve error message when adding file to X509Store fails #2249

Description

@phrinx

I'm currently trying to investigate an multi-threading issue with JRuby 1.7.16 environment where faraday/httpclient fails to load the CA file under some condition which is difficult to reproduce in development. Unfortunately it's not exactly clear to me what happens here since the error message does not tell anything about the root cause but the configured ca_file definitely exists in my case. It just says:

OpenSSL::X509::StoreError: loading file failed: null

Looking at the code it seems any exception is caught and only the message is extracted which leads to the 'null' message above.

To reproduce the 'poor' error messsage here a little snippet where I'm passing in a file which does not exist:

[79] pry(main)> conn = Faraday.new(nil, :ssl => {:ca_file => '/does/not/exist.crt'}) do |conn|
[79] pry(main)*   conn.adapter :httpclient
[79] pry(main)* end
=> #<Faraday::Connection:0x63cb34b1
 @builder=#<Faraday::RackBuilder:0x31f083a6 @handlers=[Faraday::Adapter::HTTPClient]>,
 @default_parallel_manager=nil,
 @headers={"User-Agent"=>"Faraday v0.9.0"},
 @options=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,
 @parallel_manager=nil,
 @params={},
 @proxy=nil,
 @ssl=#<struct Faraday::SSLOptions verify=nil, ca_file="/does/not/exist.crt", ca_path=nil, verify_mode=nil, cert_store=nil, client_cert=nil, client_key=nil, certificate=nil, private_key=nil, verify_depth=nil, version=nil>,
 @url_prefix=#<URI::HTTP:0x255320e7 URL:http:/>>
[80] pry(main)> conn.get 'https://www.google.com'
OpenSSL::X509::StoreError: loading file failed: null
from org/jruby/ext/openssl/X509Store.java:153:in `add_file'

It would be helpful to either create a nested exception (to not loose the root cause) or add at least the exception class to the output in case the exception message is null (so I can investigate this problem further).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions