Repository: encode/httpx
Pull request: Added docs for using client-side ssl certificates
Closes https://github.com/encode/httpx/issues/1224


Problem statement:
Document client side certificate support
Our Advanced docs don’t currently document the `cert=...` option, for client-side certificate support.
This should probably come at the bottom of the SSL Certificates section.

Requests currently has some good docs for the support there, which we might want to base our own wording on.

Hints from issue discussion:

Commit message: Added docs for using client-side ssl certificates

Patch to review:
diff --git a/docs/advanced.md b/docs/advanced.md
index 07ca28a3f7..d868cc408a 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 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
+```
+>>> 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.


Code review comments:
diff_hunk: @@ -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 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)
path: docs/advanced.md
text: @user1:
```suggestion
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)
```

diff_hunk: @@ -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 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
+```
path: docs/advanced.md
text: @user1:
```suggestion
```pycon
```