curl-and-python
Re: Convert client-certificate curl.exe command to pycurl
Date: Wed, 13 May 2015 16:08:40 +0200
On Wednesday 13 May 2015 15:31:39 Binney, Peter wrote:
> 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
Should not you write "./cookies.tmp" instead?
> 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
I would suggest to grab the verbose output in both the working and non-working
cases and compare them with each other.
Kamil
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2015-05-13