prkumar / uplink

A Declarative HTTP Client for Python
https://uplink.readthedocs.io/
MIT License
1.07k stars 61 forks source link

add docs about Client Side Certificates for 2-way ssl #212

Open wasdee opened 3 years ago

wasdee commented 3 years ago

I was expecting it in https://www.python-httpx.org/advanced/#ssl-certificates section.

I went to read the source code expecting parallel api like this. And I found it supported.

I search the docs again but it is mentioned on https://www.python-httpx.org/compatibility/#ssl-configuration and https://www.python-httpx.org/api/#helper-functions

I think it would be nice if the Advanced/SSL Section mention about this.

coreymunn3 commented 2 years ago

I was also wondering how to pass client SSL certificates as part of auth. In fact I need to pass both basic auth along with the client ssl certificate and totally stumped on how to do this with uplink. In requests its easy, simply

requests.post(url, headers=headers, data=json.dumps(data), cert=(cert_file_path, key_file_path), auth=('user','password'))

Can someone provide guidance on how to do this with Uplink?

prkumar commented 2 years ago

Hi, @coreymunn3 - If you need the cert for all requests, one option is to provide the cert using a requests.Session, as mentioned here: https://docs.python-requests.org/en/master/user/advanced/#client-side-certificates

This should work:

session = requests.Session()
session.cert = ...
consumer = MyConsumer(client=session)