Skip to content

Commit

Permalink
Added example for client-side certificates validation
Browse files Browse the repository at this point in the history
I've spent some time figuring this out on my own (and have written an answer to the only other guy on SO that asked himself the same question http://stackoverflow.com/questions/41701791/aiohttp-and-client-side-ssl-certificates/43664652#43664652)

Requests documentation is pretty straightforward about this http://docs.python-requests.org/en/master/user/advanced/#client-side-certificates

I think this will be a useful example for future users of this feature (without any high-level API changes like requests implemented).
  • Loading branch information
omerbenamram authored Apr 27, 2017
1 parent 480cffa commit 1988023
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,17 @@ pass it into the connector::
session = aiohttp.ClientSession(connector=conn)
r = await session.get('https://example.com')

If you need to verify **client-side** certificates, you can do the same thing as the previous example,
but add another call to ``load_cret_chain`` with the key pair::

sslcontext = ssl.create_default_context(
cafile='/path/to/client-side-ca-bundle.crt')
sslcontext.load_cert_chain('/path/to/client/public/key.pem', '/path/to/client/private/key.pem')
conn = aiohttp.TCPConnector(ssl_context=sslcontext)
session = aiohttp.ClientSession(connector=conn)
r = await session.get('https://server-with-client-side-certificates-validaction.com')


You may also verify certificates via MD5, SHA1, or SHA256 fingerprint::

# Attempt to connect to https://www.python.org
Expand Down

0 comments on commit 1988023

Please sign in to comment.