Method: Gem::Net::HTTP::Persistent#ssl

Defined in:
lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb

#ssl(connection) ⇒ Object

Enables SSL on connection



970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
# File 'lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb', line 970

def ssl connection
  connection.use_ssl = true

  connection.ciphers     = @ciphers     if @ciphers
  connection.ssl_timeout = @ssl_timeout if @ssl_timeout
  connection.ssl_version = @ssl_version if @ssl_version
  connection.min_version = @min_version if @min_version
  connection.max_version = @max_version if @max_version

  connection.verify_depth    = @verify_depth
  connection.verify_mode     = @verify_mode
  connection.verify_hostname = @verify_hostname if
    @verify_hostname != nil && connection.respond_to?(:verify_hostname=)

  if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
     not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
    warn "                           !!!SECURITY WARNING!!!\n\nThe SSL HTTP connection to:\n\n\#{connection.address}:\#{connection.port}\n\n                         !!!MAY NOT BE VERIFIED!!!\n\nOn your platform your OpenSSL implementation is broken.\n\nThere is no difference between the values of VERIFY_NONE and VERIFY_PEER.\n\nThis means that attempting to verify the security of SSL connections may not\nwork.  This exposes you to man-in-the-middle exploits, snooping on the\ncontents of your connection and other dangers to the security of your data.\n\nTo disable this warning define the following constant at top-level in your\napplication:\n\nI_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG = nil\n\n    WARNING\n  end\n\n  connection.ca_file = @ca_file if @ca_file\n  connection.ca_path = @ca_path if @ca_path\n\n  if @ca_file or @ca_path then\n    connection.verify_mode = OpenSSL::SSL::VERIFY_PEER\n    connection.verify_callback = @verify_callback if @verify_callback\n  end\n\n  if @certificate and @private_key then\n    connection.cert = @certificate\n    connection.key  = @private_key\n  end\n\n  connection.cert_store = if @cert_store then\n                            @cert_store\n                          else\n                            store = OpenSSL::X509::Store.new\n                            store.set_default_paths\n                            store\n                          end\nend\n"