How do you provide all the details necessary to make an HTTPS request with an SSL client certificate?
Okay, so I looked all over and found bits and pieces of what I needed. I want to provide this for anyone else that is struggling. All of the files were put in a PEM format. I used the client.key
file to create a CSR that was given to the server administrator. In return I got a P7B file that I then needed to be convert into PEM files. The root.cer
and client.cer
file came from the P7b.
uri = URI.parse(my_url_stril)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(File.read("client.cer"))
http.ca_file = 'root.cer'
http.key = OpenSSL::PKey::RSA.new(File.read("client.key"))
request = Net::HTTP::Post.new(uri.request_uri)
request.body = body
response = http.request(request)
Let me know if you need more details!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With