kennethreitz/requests — pull request #552 by slingamn (2012-04-17 01:00:47+00:00)
Title: attempt to use the OS's certificate bundle

I thought it might be a good idea to attempt to use the OS's certificate bundle on systems where one is available. I was thinking something like this:

1. It could be dangerous to install `certifi` and then forget about it, in case a CA in it is compromised (like with Diginotar).
1. Might be good not to depend on another package?

Anyway, thanks for your time.

I used github for the smoke test because, amusingly enough, httpbin's certificate didn't verify on my system (Fedora 16):

[shivaram@good-fortune ~]$ curl -v https://httpbin.org/get
* About to connect() to httpbin.org port 443 (#0)
* Trying 107.21.118.103... connected
* Connected to httpbin.org (107.21.118.103) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* Peer's certificate issuer is not recognized: 'CN=RapidSSL CA,O="GeoTrust, Inc.",C=US'
* NSS error -8179
* Closing connection #0
* Peer certificate cannot be authenticated with given CA certificates
curl: (60) Peer certificate cannot be authenticated with given CA certificates
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.