简体   繁体   中英

How to configure private key for SSL client in Ruby on Rails application

I need to debug OpenID authentication flow between Rails application and OpenID provider going over SSL. I want to configure Rails and wireshark with the same private key for SSL flow decryption.

I need to know if there is configuration option in Rails to force use private key for the SSL client.

Use the cert and key options:

require "net/https"
require "uri"

uri = URI.parse("https://secure.com/")
pem = File.read("/path/to/my.pem")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(pem)
http.key = OpenSSL::PKey::RSA.new(pem)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

request = Net::HTTP::Get.new(uri.request_uri)

From http://www.rubyinside.com/nethttp-cheat-sheet-2940.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM