ruby on rails - How can I use a PEM certificate with password? -


i'm having plenty of trouble trying use certificate has password on ruby. i'm using rest-client, that's not requirement.

this curl-equivalent of call need make:

curl -e certificate.pem:password -d ident=language -d data="test" "https://theurl"  

i tried many things, can't password part working. here's have far:

cert = openssl::x509::certificate.new(file.read("#{rails_root}/certificate.pem"))  reply = restclient.post("https://theurl", {:ident => 'language', :data => 'test'}, {:ssl_client_cert => cert}) 

i've tried putting password everywhere, :password , :ssl_client_key, i've looked through documentation find there's accept password.

this error get:

ssl_connect returned=1 errno=0 state=sslv3 read finished a: sslv3 alert handshake failure 

what missing?

the way uses curl option -e, specifying private key certificate.

(from curl man page)

-e/--cert

(ssl) tells curl use specified client certificate file when getting file https, ftps or ssl-based protocol. certificate must in pem format. if optional password isn't specified, queried on terminal. note option assumes "certificate" file private key , private certificate concatenated! see --cert , --key specify them independently.

so in order samething restclient, can try using ssl_client_key option. like:

:ssl_client_key   =>  openssl::pkey::rsa.new(file.read("key.pem"), "passphrase, if any"), 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -