Support setting SSL client cert as a an array, to configure extra_chain_cert#42
Merged
olleolleolle merged 3 commits intoAug 1, 2024
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16.