Convert client-certificate curl.exe command to pycurl

From: Binney, Peter <>
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

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

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


Received on 2015-05-13