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

Add ciphers to SSL options #1581

Closed
womblep opened this issue Aug 16, 2024 · 6 comments · Fixed by #1582
Closed

Add ciphers to SSL options #1581

womblep opened this issue Aug 16, 2024 · 6 comments · Fixed by #1582

Comments

@womblep
Copy link
Contributor

womblep commented Aug 16, 2024

I have hit a server where I needed to pin the ciphers to be able to connect. The server is most certainly badly configured but it is not something I can get changed.

I was able to work around this by monkey-patching Faraday and the Faraday Net::HTTP adapter (Net::HTTP supports ciphers) but I would like to submit patches to make it easier to do.

The Faraday change is just adding a "ciphers" member to the SSLOptions

Linked to lostisland/faraday-net_http#44

@iMacTia
Copy link
Member

iMacTia commented Aug 22, 2024

As a general rule, we only add new SSLOptions if these are general HTTP concepts or supported by most of the Faraday adapters / Ruby HTTP clients.

In this case, we know Net::HTTP supports it, and I found evidence of its support in other adapters as well:

@womblep I hope this can help getting you started. Would you have time to go through the other Faraday adapters and check how many of them support it?
Sometimes the adapter itself is just a wrapper of the underlying HTTP library (see async-http or em-http examples above), so figuring out if they support ciphers or not requires some digging

@womblep
Copy link
Contributor Author

womblep commented Aug 24, 2024

Excon - support
option params [String] :ciphers Only use the specified SSL/TLS cipher suites; use OpenSSL cipher spec format e.g. 'HIGH:!aNULL:!3DES' or 'AES256-SHA:DES-CBC3-SHA'

HTTPClient - support
# A String of OpenSSL's cipher configuration. Default value is
# ALL:!ADH:!LOW:!EXP:!MD5:+SSLv2:@strength
# See ciphers(1) man in OpenSSL for more detail.
attr_config :ciphers

Net::HTTP::Persistent - support
https://github.com/drbrain/net-http-persistent/blob/master/lib/net/http/persistent.rb#L571

Patron - the adapter doesnt look like it does any SSL options other than verify. The Patron gem doesnt look like it supports ciphers (or many SSL settings)

HTTP.rb adapter and gem use OpenSSL SSLContext which support ciphers

httpx - uses OpenSSL SSLContext so should be able to be added to the adapter in "def ssl_options_from_env(env)"

@womblep
Copy link
Contributor Author

womblep commented Aug 24, 2024

Typhoeus - supported using ssl_cipher_list

Async::HTTP - supported - I am getting lost in the adapter but I think all the SSL options are passed through Async::HTTP::Faraday::Clients.make_client. Ciphers would be passed through without any change required.

EM::HTTP - supported using cipher_list

@iMacTia
Copy link
Member

iMacTia commented Aug 24, 2024

This was great research, thank you ❤️!
I feel much more confident about adding this directly to Faraday now because it seems like we can get it supported by most adapters 💪

@iMacTia
Copy link
Member

iMacTia commented Aug 26, 2024

@womblep FYI – just released Faraday 2.11.0 with support for ciphers (and updated dependency on the net_http adapter v3.3 that contains your PR)

@womblep
Copy link
Contributor Author

womblep commented Aug 26, 2024

@iMacTia thanks for the speedy release! ❤️

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 a pull request may close this issue.

2 participants