473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

socket.ssl with key files?

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-----
MIICkTCCAfqgAwIBAgICNqUwDQYJKoZIhvcNAQEFBQAwgZ8xCz AJBgNVBAYTAlVT
<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

Jan 19 '06 #1
4 2430
Chris Curvey wrote:
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?


This might help, or it might not. If you have a passphrase on the
private key, somehow the passphrase needs to be provided as well,
but I'm unsure how.

This code is mostly untested, so you might have to modify _ssl.c
as well to make it work.

Regards,
Martin
Jan 19 '06 #2
thanks for the info.

1) Am I correct that I should just be splitting the files?
2) The passphrase question was in the back of my mind, but I guess I
need to move it to the front. Hopefully someone here will have an
idea. (I wonder if M2Crypto handles that?)

I guess it's better to know that the code is fairly untested, rather
than finding that out on my own.

-Chris

Jan 19 '06 #3
Chris Curvey wrote:
1) Am I correct that I should just be splitting the files?


Nobody knows. Just try it and report whether it works.

Regards,
Martin
Jan 19 '06 #4
Rats, you beat me to it.

It seems to work if I just give the same, combined file as the argument
to both the key_file and cert_file parameters. (that's not to say that
it doesn't work if I do something else).

In my case, the passphrase is packaged up in the xml payload and sent
over.

Thank you everyone.

Jan 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Al Wilkerson | last post by:
Is anyone aware of any special things to remember when sending Objects back in forth between Client and Sever, other than every readObject() should have a writeObject() and vice versa ? Does the...
5
by: Jean-Pierre Bergamin | last post by:
Dear python-Community We are forced to use a quite old simulation software that's based on Modula-2. The idea is now to let this software "talk" to the outside world over a TCP/IP network. ...
8
by: Paulo da Silva | last post by:
How are those "files" of type "socket", whose name begins with "=", created? How can I create them with python? Thanks.
0
by: Sean | last post by:
I am working with an OLD copy of Perl 5.004_04 with a "buggy" Socket module (version 1.6) and IO::Socket::Inet version 1.1603. The problem I am having is with Socket timeout issues - they just...
7
by: | last post by:
Hi all, I have a simple .aspx page running on net 2.0 that is trying to do a http post to a remote server. Here is the code Private Function ProcessRequests(ByVal strbody As String) As String...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
1
by: orehian | last post by:
Construct a one-time password system. · Write a server code and a client code. The server code takes as input a username and a one-time password from the client and then sends a message...
0
by: george585 | last post by:
Hello! I am new to network programming, and understand just basics. Using some sample code, and having read documentation, I managed to create a simple app in C# and VB.NET. The application is...
1
by: keksy | last post by:
Hi every1, I am writing a small client/server application and in it I want to send an image asynchronous from the client to the server through a TCP socket. I found an example code on the MSDN...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.