Re: curl-and-python Digest, Vol 60, Issue 2

From: John Skopis <>
Date: Tue, 16 Aug 2011 10:22:33 -0500

On 08/16/2011 05:00 AM, wrote:
>> I am wondering if you know of a better way to initialize setup CAINFO to
>> > something useful besides hardcoding the path in do_curl_new. Running strings
>> > on libcurl reveals the path to CAINFO.
> libcurl has a default path for CAINFO set internally. If you need to change
> that then it is entirely up to your app how to do it!

The app is pycurl. Running the test below fails because CAINFO is set to
None in pycurl.

I am wondering what is the best way to initialize pycurl.CAINFO, using
the library default?

If you look at the earlier code, I had hardcoded setting the path in the
pycurl Curl constructor. Rather than hardcoding the path I think it
makes more sense to ask libcurl for the default path.

Or, did I compile libcurl incorrectly? Is curl supposed to use the
deafult if CAINFO/CAPATH is not set?

Thanks again,

import sys
import pycurl

class Test:
     def __init__(self):
         self.contents = ''

     def body_callback(self, buf):
         self.contents = self.contents + buf

print >>sys.stderr, 'Testing', pycurl.version

t = Test()
c = pycurl.Curl()
c.setopt(c.URL, '')
c.setopt(c.WRITEFUNCTION, t.body_callback)

print t.contents

Received on 2011-08-16