graphql-python/gql

mTLS authentication

peppermintea opened this issue · 3 comments

Hello,

Does gql support mTLS ?

This is an example with requests library:
https://requests.readthedocs.io/en/latest/user/advanced/#client-side-certificates

Thank you!

Any extra argument passed to the RequestsHTTPTransport init (kwargs) will be passed to the request method of the requests session.

So you should be able to use client certificates by filling the cert argument in the transport:

transport = RequestsHTTPTransport(
    url="https://countries.trevorblades.com/",
    cert= ('/path/client.cert', '/path/client.key'),
)

Also if your backend supports websockets and also supports doing queries and mutations on the websocket endpoint, then it could be better to use the websockets transport which can be configured for client certificates.

Thanks!