curl-and-python

Re: Convert client-certificate curl.exe command to pycurl

From: Dima Tisnek <dimaqq_at_gmail.com>
Date: Wed, 13 May 2015 15:48:21 +0200

Peter, please enable debug (verbose output) and I think you will be
able to track what went wrong.

On 13 May 2015 at 15:31, Binney, Peter <Peter.Binney_at_commerzbank.com> 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
> 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
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2015-05-13