How do I use a client certificate using HTTPS?
1 answer
Ok, so I looked around and found pieces of what I need. I want to provide this for everyone who is struggling. All files were placed in PEM format. I used a file client.key
to generate the CSR that was provided to the server admin. In return, I got a P7B file, which I then needed to convert to PEM files. Files root.cer
and client.cer
came from 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 information!
+1
source to share