Skip to content

Conversation

@bf4
Copy link
Contributor

@bf4 bf4 commented Feb 28, 2025

The HTTPX gem supports this OpenSSL::SSL::SSLSocket#hostname= option

Description

The HTTPX gem supports the ssl option hostname= but, when using the Faraday adapter, it raises an error

NameError: no member 'hostname' in struct (NameError)

        target[key] = if value.is_a?(Hash) && (target[key].is_a?(Hash) || target[key].is_a?(Options))
              ^^^^^^^

This option is defined as OpenSSL::SSL::SSLSocket#hostname and looks like it has been around a long time ruby/openssl#81

I've found it helpful when using a SOCKS5 proxy and I want to set the hostname for use in verifying the certificate. Without this change, I need to set OpenSSL::SSL::VERIFY_NONE

Todos

Not sure if tests or documentation are needed

Additional Notes

Happy to make any changes needed.

The HTTPX gem supports this OpenSSL::SSL::SSLSocket#hostname= option
@iMacTia
Copy link
Member

iMacTia commented Apr 8, 2025

Sorry @bf4 I somehow missed this until now, taking a look now 👀

@iMacTia
Copy link
Member

iMacTia commented Apr 8, 2025

OK so a couple minor fixes are needed to make this ready to merge. I've found this old PR doing something similar that you can use as a guideline.

  1. Update the docs/customization/ssl-options.md file with the new option;
  2. Fix the failing utils_spec.rb

@bf4
Copy link
Contributor Author

bf4 commented Apr 8, 2025

Thanks @iMacTia for the helpful reference PR. Pushed a new commit

@bf4
Copy link
Contributor Author

bf4 commented Apr 8, 2025

Merge branch 'main' into patch-1

Thanks 😊 I should have done that 🤦

# #
# # @!attribute hostname
# # @return [String] SNI hostname (see https://ruby.github.io/openssl/OpenSSL/SSL/SSLSocket.html#method-i-hostname-3D)
# # @return [String] Server hostname used for SNI (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL/SSLSocket.html#method-i-hostname-3D)
Copy link
Member

Choose a reason for hiding this comment

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

Hm, is that a very old Ruby docs link?

Copy link
Contributor Author

@bf4 bf4 Apr 8, 2025

Choose a reason for hiding this comment

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

Agreed.. was just being consistent within the file without expanding scope to change more.

The two files also use different docs paths.

I'm not surprised you noticed as well given how small the pr is

Copy link
Member

@iMacTia iMacTia Apr 8, 2025

Choose a reason for hiding this comment

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

Ahaha yeah the ciphers comment also points to 2.5.1! Definitely needs an update but agree we can do that in a follow-up PR 👍

@iMacTia iMacTia merged commit 919dc8f into lostisland:main Apr 8, 2025
7 checks passed
@bf4 bf4 deleted the patch-1 branch April 8, 2025 20:49
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