curl-and-python

Convert client-certificate curl.exe command to pycurl

From: Binney, Peter <Peter.Binney_at_commerzbank.com>
Date: Wed, 13 May 2015 15:31:39 +0200

I am using a command-line call to fetch pages from a client-certificated site using a passworded .pem certificate. eg:

   curl -s --cert ./ResMon.pem:Password --cacert ./rootAndCA.pem --location --cookie-jar ./cookies.tmp https://wiki.ib.internal

When I try to do this with pycurl the site is not presented with the client certificate and so returns a "you must login" page.
I have tried numerous variations of the under-documented setopt options. My current version is:

import pycurl
import cStringIO

fPointer = cStringIO.StringIO()
curl = pycurl.Curl()
curl.setopt(curl.URL, "https://wiki.ib.internal")
curl.setopt(pycurl.WRITEFUNCTION, fPointer.write)
curl.setopt(curl.CAINFO, CERTS + "./rootAndCA.pem")
curl.setopt(curl.SSLCERT, CERTS + "./ResMon.pem")
curl.setopt(curl.SSLCERTPASSWD, " Password ")
curl.setopt(pycurl.FOLLOWLOCATION, 1) ## cf: --location
curl.setopt(pycurl.COOKIEFILE, '') ## cf: --cookie-jar
curl.perform()

print("Response code: " + str(curl.getinfo(pycurl.RESPONSE_CODE)))
print(fPointer.getvalue())

Basically, the SSLCERTxxx information is not being used.
What am I missing please?

Thanks,
Peter

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2015-05-13