curl-and-python

Re: Making https requests, using x509 certificate

From: <johansen_at_sun.com>
Date: Thu, 16 Jul 2009 14:47:27 -0700

On Mon, Jul 06, 2009 at 10:45:50AM +0300, ?????? Lacrima wrote:
> import pycurl
> import StringIO
> b = StringIO.StringIO()
> c = pycurl.Curl()
> url = 'https://example.com/'
> c.setopt(pycurl.URL, url)
> c.setopt(pycurl.WRITEFUNCTION, b.write)
> c.setopt(pycurl.CAINFO, 'cert.crt')
> c.setopt(pycurl.SSLKEY, 'mykey.key')
> c.setopt(pycurl.SSLCERT, 'mycert.cer')
> c.setopt(pycurl.SSLKEYPASSWD , 'pass phrase')
> c.perform()

There's a subtle problem here that I forgot to track down the last time
I had to deal with this code. In particular, pycurl seems to set CAINFO
and CAPATH to their default values simultaneously, which may lead to
some confusion. I setup my consumer to use CAPATH, and had to call
c.unsetopt(pycurl.CAINFO) in order to get things to work properly. I
had forgotten that I'd run into this difficulty until you sent this
e-mail.

The other possibility is that pycurl can't find the certificate that
you've supplied in the argument to CAINFO. You might try supplying a
full path as the arugment to CAINFO instead.

-j
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2009-07-16