From: Aaron Samuel Date: 2011-10-11T11:49:12+09:00 Subject: Re: Using PKCS12 Cert for OpenSSL --0016e648b054ca807c04aefcb3d2 Content-Type: text/plain; charset=UTF-8 Just as a precaution, becareful you haven't pasted any additional spaces into either file. Windows copy/paste has niche for doing that. On Oct 10, 2011 2:58 PM, "Jeff Miller" wrote: > Hello everyone, > I'm having an issue trying to setup my RoR app to use a particular > certificate for an XML transaction... The certificate I'm given is a > .p12 file, containing 3 certificates and a private key. The certificates > are: CA root, CA intermediate, and CA issuing. This is the first time > I've really done any kind of secure XML send / receive transaction and > I'm getting a bit stuck -- perhaps you all can drop some knowledge on me > :) > > So I've converted my .p12 certificate into a .cer (with the 3 > certificates inside, marked by ---BEGIN CERTIFICATE--- and ---END > CERTIFICATE---) and .key file (with the private key). > > Here's my ruby code. I've mostly been testing in console. > > url = URI.parse(test_url) # Testing > http = Net::HTTP.new(url.host, url.port) > http.use_ssl = true > http.cert = > > OpenSSL::X509::Certificate.new(File.read(File.join(Rails.root.join('lib/api'), > "test.cer"))) > http.key = > OpenSSL::PKey::RSA.new((File.read(File.join(Rails.root.join('lib/api'), > "test.key"))),cert_password) > > response = http.post(url.host, known_good_xml) > > Here is the result of the last line: > OpenSSL::SSL::SSLError: SSL_CTX_use_PrivateKey:: key values mismatch > > Since I'm new to this, I'm having a hard time trying to figure out > whether my problem is with my cert, my ruby code, or whatever... > > Any and all help is appreciated! > > Thanks, > - Jeff > > -- > Posted via http://www.ruby-forum.com/. > > --0016e648b054ca807c04aefcb3d2--