-
Notifications
You must be signed in to change notification settings - Fork 9
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,7 +183,8 @@ def request_with_wrapped_block(http, env) | |
ca_file: :ca_file, | ||
ssl_version: :version, | ||
min_version: :min_version, | ||
max_version: :max_version | ||
max_version: :max_version, | ||
verify_hostname: :verify_hostname | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
}.freeze | ||
|
||
def configure_ssl(http, ssl) | ||
|
@@ -193,7 +194,7 @@ def configure_ssl(http, ssl) | |
http_set(http, :cert_store, ssl_cert_store(ssl)) | ||
|
||
SSL_CONFIGURATIONS | ||
.select { |_, key| ssl[key] } | ||
.select { |_, key| !ssl[key].nil? } | ||
.each { |target, key| http_set(http, target, ssl[key]) } | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,18 @@ | |
expect(http.pool.size).to eq(5) if http.respond_to?(:pool) | ||
end | ||
|
||
it "allows to set verify_hostname in SSL settings to false" do | ||
url = URI("https://example.com") | ||
|
||
adapter = described_class.new(nil) | ||
|
||
http = adapter.send(:connection, url: url, request: {}) | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're depending on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, removed all the |
||
end | ||
|
||
context "min_version" do | ||
it "allows to set min_version in SSL settings" do | ||
url = URI("https://example.com") | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we now depend on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, removed all the |
||
expect(http.min_version).to eq(:TLS1_2) if http.respond_to?(:min_version) | ||
end | ||
end | ||
|
There was a problem hiding this comment.
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 until5.0
, we could do either:"~> 4.0", ">= 4.0.4"
; or">= 4.0.4", "< 5"
There was a problem hiding this comment.
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 arespond_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+
to4.0.4+
, so happy to keep the higher version constraintThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I've opted for
">= 4.0.4", "< 5"
since it's very literal.