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 configuration always occurs even when connecting to HTTP #37

Closed
ma2gedev opened this issue Jul 23, 2024 · 2 comments
Closed

SSL configuration always occurs even when connecting to HTTP #37

ma2gedev opened this issue Jul 23, 2024 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@ma2gedev
Copy link
Contributor

Description

Even when connecting to HTTP, the initialization of the cert store (OpenSSL::X509::Store.new) always occurs. Depending on the environment, this unnecessary initialization process could lead to performance degradation.

In Faraday::Adapter::NetHttp#configure_ssl, there is a line return unless ssl to return early. However, the ssl passed here is an instance of Faraday::SSLOptions, so the SSL configuration process always occurs without returning early.

Environment information

faraday version: 2.10.0
faraday-net_http version: 3.1.0

Steps to reproduce

Perform a connection to http with the following code:

Faraday.new(url: 'http://example.com').get '/'

You can confirm that OpenSSL::X509::Store.new is always called.

Expected result

When connecting to HTTP, OpenSSL::X509::Store.new should not be called.

Reference information

It seems that other adapters also check whether it is https scheme when performing the ssl configuration process.

I think faraday-net_http also need to check whether the scheme is https as a condition for early return.

@iMacTia iMacTia added bug Something isn't working good first issue Good for newcomers labels Jul 23, 2024
@iMacTia
Copy link
Member

iMacTia commented Jul 23, 2024

Thank you for reporting this issue @ma2gedev, agree it's worth taking a closer look and it should be relatively straightforward to fix.
I'm on holiday until later next month so I won't have time to look into this until then, but a PR would be welcome (and maybe @olleolleolle could review before I'm back).

ma2gedev added a commit to ma2gedev/faraday-net_http that referenced this issue Jul 24, 2024
`env[:ssl]` is an instance of `Faraday::SSLOptions`, and as a result,
`configure_ssl` is always executed, even when the connection is to HTTP.
Fixes lostisland#37
ma2gedev added a commit to ma2gedev/faraday-net_http that referenced this issue Jul 24, 2024
`env[:ssl]` is an instance of `Faraday::SSLOptions`, and as a result,
`configure_ssl` is always executed, even when the connection is to HTTP.
Fixes lostisland#37
@ma2gedev
Copy link
Contributor Author

@iMacTia @olleolleolle

Thank you for your reply. I just created a PR #38 . Could you please review it? Thank you in advance.

ma2gedev added a commit to ma2gedev/faraday-net_http that referenced this issue Jul 24, 2024
`env[:ssl]` is an instance of `Faraday::SSLOptions`, and as a result,
`configure_ssl` is always executed, even when the connection is to HTTP.
Fixes lostisland#37
olleolleolle pushed a commit that referenced this issue Jul 24, 2024
`env[:ssl]` is an instance of `Faraday::SSLOptions`, and as a result,
`configure_ssl` is always executed, even when the connection is to HTTP.
Fixes #37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants