From: Hemanth kumar Date: Tue, 13 Apr 2021 12:08:22 +0000 (+0530) Subject: Added docs for using client-side ssl certificates (#1570) X-Git-Tag: 0.18.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=535df6c99832ce65167e6bf36c5b7834a5bb3fe0;p=thirdparty%2Fhttpx.git Added docs for using client-side ssl certificates (#1570) * Added docs for using client-side ssl certificates * Update docs/advanced.md Co-authored-by: Joe * Update docs/advanced.md Co-authored-by: Joe * Update docs/advanced.md * Update docs/advanced.md * Update docs/advanced.md Co-authored-by: Hemanth Co-authored-by: Tom Christie Co-authored-by: Joe --- diff --git a/docs/advanced.md b/docs/advanced.md index 07ca28a3..1902b0ee 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -945,6 +945,32 @@ client = httpx.Client(verify=False) The `client.get(...)` method and other request methods *do not* support changing the SSL settings on a per-request basis. If you need different SSL settings in different cases you should use more that one client instance, with different settings on each. Each client will then be using an isolated connection pool with a specific fixed SSL configuration on all connections within that pool. +### Client Side Certificates + +You can also specify a local cert to use as a client-side certificate, either a path to an SSL certificate file, or two-tuple of (certificate file, key file), or a three-tuple of (certificate file, key file, password) + +```python +import httpx + +r = httpx.get("https://example.org", cert="path/to/client.pem") +``` + +Alternatively, + +```pycon +>>> cert = ("path/to/client.pem", "path/to/client.key") +>>> httpx.get("https://example.org", cert=cert) + +``` + +or + +```pycon +>>> cert = ("path/to/client.pem", "path/to/client.key", "password") +>>> httpx.get("https://example.org", cert=cert) + +``` + ### Making HTTPS requests to a local server When making requests to local servers, such as a development server running on `localhost`, you will typically be using unencrypted HTTP connections.