socket.ssl with key files?

Chris Curvey ccurvey at gmail.com
Wed Jan 18 20:06:12 EST 2006


I need to use socket.ssl() to open a connection using key files.  I
have been provided with a text file called cert_key_pem.txt containing
my keys that looks like this:

-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDKwLuk/UpICOnZvH3mf9rFQvCkDPA8XQZLpa80Z0liMVYu4GQT
<snip>
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIICkTCCAfqgAwIBAgICNqUwDQYJKoZIhvcNAQEFBQAwgZ8xCzAJBgNVBAYTAlVT
<snip>
-----END CERTIFICATE-----

I see that socket.ssl takes "keyfile" and "certfile" parameters.  So do
I just take the text file that I've been given and break it into two
files, then specify those file names when I open the connection?  At
the moment, I'm getting

  File "/usr/local/lib/python2.4/httplib.py", line 1070, in connect
    ssl = socket.ssl(sock, self.key_file, self.cert_file)
  File "/usr/local/lib/python2.4/socket.py", line 74, in ssl
    return _realssl(sock, keyfile, certfile)
socket.sslerror: (1, 'error:14094410:SSL routines:SSL3_READ_BYTES:sslv3
alert handshake failure')

Many thanks for any ideas!

-Chris




More information about the Python-list mailing list