Skip to content
Myr

Merge pull request #3057 from kevinburke/secure-by-default

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Clarify that SSL verification is on by default

authored by Cory Benfield · committed by Cory Benfield · parents 190cddd, e94c812 · Browse files · 1 file+8 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−7 removed

  • other:+8 added−7 removed

1 file+8 added−7 removed

modified:docs/user/advanced.rst+8 added-7 removed
190 unmodified lines
191192SSL Cert Verification193---------------------194195Requests can verify SSL certificates for HTTPS requests, just like a web browser.196To check a host's SSL certificate, you can use the ``verify`` argument::195Requests verifies SSL certificates for HTTPS requests, just like a web browser.196By default, SSL verification is enabled, and requests will throw a SSLError if197it's unable to verify the certificate::198198 >>> requests.get('https://kennethreitz.com', verify=True)199 requests.exceptions.SSLError: hostname 'kennethreitz.com' doesn't match either of '*.herokuapp.com', 'herokuapp.com'199 >>> requests.get('https://requestb.in')200 requests.exceptions.SSLError: hostname 'requestb.in' doesn't match either of '*.herokuapp.com', 'herokuapp.com'201201I don't have SSL setup on this domain, so it fails. Excellent. GitHub does though::202I don't have SSL setup on this domain, so it throws an exception. Excellent. GitHub does though::203203 >>> requests.get('https://github.com', verify=True)204 >>> requests.get('https://github.com')205 <Response [200]>206207You can pass ``verify`` the path to a CA_BUNDLE file or directory with certificates of trusted CAs::208
16 unmodified lines
225226 >>> requests.get('https://kennethreitz.com', cert=('/path/client.cert', '/path/client.key'))227 <Response [200]>228228If you specify a wrong path or an invalid cert::229If you specify a wrong path or an invalid cert, you'll get a SSLError::230231 >>> requests.get('https://kennethreitz.com', cert='/wrong_path/client.pem')232 SSLError: [Errno 336265225] _ssl.c:347: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib233
681 unmodified lines