Skip to content

How do I authenticate AsyncIO client with certs (mTLS) #1040

Answered by bhakta0007
bhakta0007 asked this question in Q&A
Discussion options

You must be logged in to vote

Can we add this to the documentation as an example usage

[pls feel free to edit the contents]

Using client certificates to establish mTLS session with server and authenticating self signed server certificates:

loop = asyncio.get_event_loop()

# The assumption here is that the client needs to present valid certs in order to connect to the server
# the client certs are available at some location
# This is the wss:// case with additional client certificate validation (mTLS - or mutual TLS)

# Optionally, we can authenticate the server cert (recommended)
authenticate_server = True

if authenticate_server:
    ssl_ctx = ssl.create_default_context()
    # if server is using a trusted authority …

Replies: 5 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@miguelgrinberg
Comment options

@bhakta0007
Comment options

@miguelgrinberg
Comment options

@bhakta0007
Comment options

Comment options

You must be logged in to vote
4 replies
@miguelgrinberg
Comment options

@bhakta0007
Comment options

@bhakta0007
Comment options

@miguelgrinberg
Comment options

Answer selected by bhakta0007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants