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

Support setting SSL client cert as a an array, to configure extra_chain_cert #42

Merged

Conversation

olleolleolle
Copy link
Member

Fixes #16.

When only one cert, how bad is it to create empty array for http.extra_chain_cert?
Do not like the if statement, nor do I like the empty array.
Need to sleep on it...
Tested locally using 3.1.4 and got:
warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).

Checked the keyword vs literal on 3.3.4, Yes it behaves differently.

irb(main):008> ssl_options_without_literal_hash = Faraday::SSLOptions.new(client_cert: "this is my string")
=> #<struct Faraday::SSLOptions verify=nil, verify_hostname=nil, ca_file=nil, ca_path=nil, verify_mode=nil, cert_store=nil, client_cert="this is my string", client_key=nil, certificate=nil, private_key=nil, verify_depth=nil, version=nil, min_version=nil, max_version=...
irb(main):009> ssl_options_with_literal_hash = Faraday::SSLOptions.new({client_cert: "this is my string"})
=>
...
irb(main):010> ssl_options_with_literal_hash
=>
 verify={:client_cert=>"this is my string"},
 verify_hostname=nil,
 ca_file=nil,
 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,
 min_version=nil,
 max_version=nil>

Looked closer at other tests.
Thanks for all the good examples.
Found a way that should be more compatible: (Well, it worked on my machine with 3.1.4 and 3.3.4 :-D )

  let(:ssl_options) do
    Faraday::SSLOptions.new.tap do |ssl_options|
      ssl_options.client_cert = cert
    end
  end
@olleolleolle olleolleolle merged commit 1dd1e64 into lostisland:main Aug 1, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Support offering client certificate as array (chain) in ssl option :client_cert
2 participants