curl-and-python

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

From: Binney, Peter <Peter.Binney_at_commerzbank.com>
Date: Wed, 13 May 2015 16:12:29 +0200

Not in my experience with pycurl. A blank string seems to mean "use your own cookie jar for the lifetime of this object".
As with so much pycurl-ery, I have been unable to find that documented, but it is the case, empirically.

-----Original Message-----
From: Kamil Dudka [mailto:kdudka_at_redhat.com]
Sent: Wednesday, May 13, 2015 3:09 PM
To: Binney, Peter
Cc: curl-and-python_at_cool.haxx.se
Subject: Re: Convert client-certificate curl.exe command to pycurl

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