]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Added docs for using client-side ssl certificates (#1570)
authorHemanth kumar <hemanth7787@gmail.com>
Tue, 13 Apr 2021 12:08:22 +0000 (17:38 +0530)
committerGitHub <noreply@github.com>
Tue, 13 Apr 2021 12:08:22 +0000 (20:08 +0800)
* Added docs for using client-side ssl certificates

* Update docs/advanced.md

Co-authored-by: Joe <nigelchiang@outlook.com>
* Update docs/advanced.md

Co-authored-by: Joe <nigelchiang@outlook.com>
* Update docs/advanced.md

* Update docs/advanced.md

* Update docs/advanced.md

Co-authored-by: Hemanth <hemanth@actionfi.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
Co-authored-by: Joe <nigelchiang@outlook.com>
docs/advanced.md

index 07ca28a3f7cd8f1dd038494900d953fa14e7b7a4..1902b0eeb5f39493a61d504c81284108dad6f610 100644 (file)
@@ -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)
+<Response [200 OK]>
+```
+
+or
+
+```pycon
+>>> cert = ("path/to/client.pem", "path/to/client.key", "password")
+>>> httpx.get("https://example.org", cert=cert)
+<Response [200 OK]>
+```
+
 ### 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.