diff --git a/lib/persistent_http/connection.rb b/lib/persistent_http/connection.rb index f56cc95..32eaf9a 100644 --- a/lib/persistent_http/connection.rb +++ b/lib/persistent_http/connection.rb @@ -123,6 +123,20 @@ class Connection # SSL verification callback. Used when ca_file is set. attr_accessor :verify_callback + ## + # HTTPS verify_depth + # Sets or returns the maximum depth for the certificate chain verification. + # https://github.com/ruby/ruby/blob/ruby_3_2/lib/net/http.rb#L1521-L1522 + attr_accessor :verify_depth + + ## + # HTTPS verify_hostname + # Sets or returns whether to verify that the server certificate is valid + # for the hostname. + # See {OpenSSL::SSL::SSLContext#verify_hostname=}[rdoc-ref:OpenSSL::SSL::SSLContext#attribute-i-verify_mode]. + # https://github.com/ruby/ruby/blob/ruby_3_2/lib/net/http.rb#L1529-L1532 + attr_accessor :verify_hostname + ## # HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_NONE which ignores # certificate problems. @@ -168,6 +182,8 @@ def initialize(options={}) @read_timeout = options[:read_timeout] @use_ssl = options[:use_ssl] @verify_callback = options[:verify_callback] + @verify_depth = options[:verify_depth] + @verify_hostname = options[:verify_hostname] @verify_mode = options[:verify_mode] @after_connect = options[:after_connect] # Because maybe we want a non-persistent connection and are just using this for the proxy stuff @@ -398,6 +414,8 @@ def ssl end @connection.verify_mode = @verify_mode if @verify_mode + @connection.verify_depth = @verify_depth if @verify_depth + @connection.verify_hostname = @verify_hostname unless @verify_hostname.nil? # This is a negative, false to turn off end end end