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 verify_hostname #25

Merged
merged 3 commits into from
Sep 16, 2024
Merged

Conversation

stefanmb
Copy link
Contributor

@stefanmb stefanmb commented Sep 9, 2024

The SSL option verify_hostname is now supported in net-http-persistent 4.0.4:

This trivial PR passes through the verify_hostname option so this feature can be used.

Would it be possible to get a new version of the adapter released? @olleolleolle @iMacTia

@stefanmb stefanmb marked this pull request as ready for review September 9, 2024 17:27
@@ -184,6 +184,7 @@ def request_with_wrapped_block(http, env)
ssl_version: :version,
min_version: :min_version,
max_version: :max_version
verify_hostname: :verify_hostname
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Faraday defaults this option to true, so we don't need to hardcode any default in the adapter.

@stefanmb stefanmb force-pushed the stefanmb/verify_hostname branch from 640f7c9 to 17e8020 Compare September 9, 2024 19:41
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_dependency "faraday", "~> 2.5"
spec.add_dependency "net-http-persistent", "~> 4.0"
spec.add_dependency "net-http-persistent", "~> 4.0.4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will also lock the version to be <= 4.1, which is probably too restrictive.
If we need 4.0.4 as a minimum version, but still want to allow any version until 5.0, we could do either:

  • "~> 4.0", ">= 4.0.4"; or
  • ">= 4.0.4", "< 5"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative is to leave ~> 4.0 as the min version and change the code to support both version (maybe with a respond_to? check. If we do this, you can disregard my other comment on specs.

Personally tough, I don't think it's gonna be a big ask to ask users to upgrade form 4.0+ to 4.0.4+, so happy to keep the higher version constraint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to keep the higher version constraint

Done, I've opted for ">= 4.0.4", "< 5" since it's very literal.

@@ -50,7 +62,7 @@
http = adapter.send(:connection, url: url, request: {})
adapter.send(:configure_ssl, http, min_version: :TLS1_2)

# `min_version` is only present in net_http_persistent >= 3.1 (UNRELEASED)
# `min_version` is only present in net_http_persistent >= 3.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we now depend on Net::HTTP::Persistent v4+, we don't need this respond_to?(:min_version) check anymore 🙌

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, removed all the respond_to? checks for old net_http_persistent versions and their respective comments.

adapter.send(:configure_ssl, http, verify_hostname: false)

# `verify_hostname` is only present in net_http_persistent >= 4.0.4
expect(http.verify_hostname).to eq(false) if http.respond_to?(:verify_hostname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're depending on v4.0.4+, we don't need to check for the presence of verify_hostname

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, removed all the respond_to? checks for old net_http_persistent versions and their respective comments.

Copy link
Member

@iMacTia iMacTia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing all the previous comments @stefanmb, this LGTM now 🚀 !

@iMacTia iMacTia merged commit 77febb6 into lostisland:main Sep 16, 2024
7 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.

3 participants