def ssl connection
connection.use_ssl = true
connection.ssl_version = @ssl_version if @ssl_version
connection.verify_mode = @verify_mode
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"
end
if @ca_file then
connection.ca_file = @ca_file
connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
connection.verify_callback = @verify_callback if @verify_callback
end
if @certificate and @private_key then
connection.cert = @certificate
connection.key = @private_key
end
connection.cert_store = if @cert_store then
@cert_store
else
store = OpenSSL::X509::Store.new
store.set_default_paths
store
end
end