title: Python Uvicorn – obtain SSL certificate information
body: <p>I have a gunicorn + uvicorn + fastApi stack. 
  (Basically, I am using <a href="https://hub.docker.com/r/tiangolo/uvicorn-gunicorn-fastapi" rel="nofollow noreferrer">https://hub.docker.com/r/tiangolo/uvicorn-gunicorn-fastapi</a> docker image).</p>
  
  <p>I've already implemented SSL based authentication by providing appropriate gunicorn configuration options: certfile, keyfile, ca_certs, cert_reqs. 
  And it works fine: user have to provide a client SSL certificate in order to be able to make an API calls.</p>
  
  <p>What I need to do now is to obtain client certificate data and pass it further (add it to request headers) into my application, since it contains some client credentials.
  For example, I've found a way to do it using gunicorn worker by overrding <code>gunicorn.workers.sync.SyncWorker</code>: <a href="https://gist.github.com/jmvrbanac/089540b255d6b40ca555c8e7ee484c13" rel="nofollow noreferrer">https://gist.github.com/jmvrbanac/089540b255d6b40ca555c8e7ee484c13</a>.</p>
  
  <p>But is there a way to do the same thing using <code>UvicornWorker</code>? I've tried to look through the <code>UvicornWorker</code>'s source code, but didn't find a way to do it.</p>
  
  <p>I went deeper into the Uvicorn source code, and as far as I understand, in order to access the client TLS certificate data, I need to do some tricks with python asyncio library (<a href="https://docs.python.org/3/library/asyncio-eventloop.html" rel="nofollow noreferrer">https://docs.python.org/3/library/asyncio-eventloop.html</a>), possibly with Server (<a href="https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.Server" rel="nofollow noreferrer">https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.Server</a>) class and override some of the <code>UvicornWorker</code>'s methods.
  I am still not quite sure if it is possible to achieve the desired result though.</p>