2
votes

I'm trying to use a p12 file and password to open an https page using RestClient in ruby.

p12 = OpenSSL::PKCS12.new(File.read("#{RAILS_ROOT}/file.p12"), "pass")

resp = RestClient::Resource.new(url, :ssl_client_key => p12.key).get

than I get:

SSL_connect returned=1 errno=0 state=SSLv3 read finished A: sslv3 alert handshake failure

(RestClient is not mandatory - anything else will do)

what am I missing?

2

2 Answers

1
votes

You must install openssl package and reinstall ruby. Not sure that important:

rmdir $rvm_path/usr/ssl/certs
ln -s /etc/ssl/certs $rvm_path/usr/ssl

Necesery:

rvm pkg install openssl
rvm <(if exist) re>install <RUBY_VERSION> --with-openssl-dir=$rvm_path/usr
0
votes

You need to import your file.p12 file into your nssdb location.

mkdir /root/nssdb
pk12util -i /path-to/your/file.p12 -d /root/nssdb
certutil -L -d /root/nssdb/
export SSL_DIR = /root/nssdb

curl -X POST -H "Content-Type: text/xml" --data "#{xml}" --cert cert:password "https://yoururl.com" -v -k
chmod -R 777 /root/nssdb
chown -R user /root/nssdb

Embed this curl call in your ruby client. It will work.

Note: If you are using a different ssl version you need to add --tlsv1.0 to the curl command