Skip to content

Commit 7b95cab

Browse files
committed
Document Connector's verify_ssl and ssl_context parameters
1 parent de528d0 commit 7b95cab

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/client.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,32 @@ Most widly used is :class:`aiohttp.connector.TCPConnector`::
346346
>>> r = yield from aiohttp.request('get', 'http://python.org', connector=conn)
347347

348348

349+
SSL control for tcp sockets
350+
---------------------------
351+
352+
:class:`aiohttp.connector.TCPConnector` constructor accepts mutually
353+
exclusive *verify_ssl* and *ssl_context* params.
354+
355+
By default it uses strict checks for HTTPS protocol. Certification
356+
checks can be relaxed by passing ``verify_ssl=False``::
357+
358+
>>> conn = aiohttp.TCPConnector(verify_ssl=False)
359+
>>> r = yield from aiohttp.request('get',
360+
... 'https://example.com', connector=conn)
361+
362+
363+
If you need to setup custom ssl parameters (use own certification
364+
files for example) you can create :class:`ssl.SSLContext` instance and
365+
pass it into connector::
366+
367+
>>> sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
368+
>>> context.verify_mode = ssl.CERT_REQUIRED
369+
>>> context.load_verify_locations("/etc/ssl/certs/ca-bundle.crt")
370+
>>> conn = aiohttp.TCPConnector(verify_ssl=False)
371+
>>> r = yield from aiohttp.request('get',
372+
... 'https://example.com', connector=conn)
373+
374+
349375
Unix domain sockets
350376
-------------------
351377

0 commit comments

Comments
 (0)