[pyOpenSSL] Help with ssl connection using X.509 objects

Manish Rai Jain manishrjain at gmail.com
Mon Oct 17 19:01:28 CEST 2005


Hi
I am trying to connect to an JAVA based SSL server, which is using
X.509certificates.
Here is the java code:
*******************************************************************************

> SSLContext ctx;
>  KeyManagerFactory kmf;
> KeyStore ks;
> char[] passphrase = pass.toCharArray();
> ctx = SSLContext.getInstance("TLS");
> kmf = KeyManagerFactory.getInstance("SunX509");
> ks = KeyStore.getInstance("PKCS12");
> File keyFile = new File(keyfile);
> if (keyFile.canRead()) {
> ks.load(new FileInputStream(keyFile), passphrase);
> System.out.println("Key file loaded...");
> kmf.init(ks, passphrase);
> ctx.init(kmf.getKeyManagers(), null, null);
> factory = ctx.getSocketFactory();
> }

*********************************************************************

Here is my implementation of python code:
############################

> ctx = SSL.Context(SSL.TLSv1_METHOD)
> # ctx.set_verify(SSL.VERIFY_PEER, verify_cb)
>
> #Get X509 certificate and the private key from the
> #initial .p12 file provided to network client
> f = open(pkey)
>
> pkcs12Obj = crypto.load_pkcs12(f.read(), passPhrase)
> x509Obj = pkcs12Obj.get_certificate()
> pkeyObj = pkcs12Obj.get_privatekey()
>
> ctx.use_privatekey(pkeyObj)
> ctx.use_certificate(x509Obj)
>
> self.sock = SSL.Connection(ctx, socket.socket(socket.AF_INET,
> socket.SOCK_STREAM))
>
###################################################

But, the code doesn't seem to work. Apparently it can connect, and do the
handshake w/o raising any interrupt, but, it is unable to gain any response
from the server. However, on similar conditions, the java code does get
response.

Any thing I am missing/ any suggestions?

Thanks
Regards
Manish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pyopenssl-users/attachments/20051018/b6ccd7bf/attachment.html>


More information about the pyopenssl-users mailing list