title: Detect SSL/TLS Client Authentication with Python?
body: <p>I have multiple Web Servers (mostly IIS &amp; Apache). </p>
  
  <p>Some of them are configured to allow only clients with a specific certificate. Moreover, we have users that have multiple certificates for the same web server which allows different actions to be made. </p>
  
  <p><strong>Ex</strong> : Certificates that are used only for highly privileged actions and some for everyday use.</p>
  
  <p>We do not use the operating system certificate store for compliance issues.</p>
  
  <p>I have made the following python code which works by specifying the wanted certificate :</p>
  
  <pre><code>import requests
  response = requests.get("https://myserver-dns-name.com", cert="./ClientCert.Key")
  </code></pre>
  
  <p>I tried fetching the server certificate and look for the following enhanced key usage oid <em>1.3.6.1.5.5.7.3.1</em> (TLS Server Auth) but not all servers have it specified.</p>
  
  <p>I tried using the Python ssl library and handle the handshake but the library doesn't seems to allow it. What I wanted is have a callback when the server sends a certificate request to the client.</p>
  
  <p>What I want to know is if its possible to detect from the client that the server have client authentication enforced in Python or any other languages?</p>
  
  <p>I want to implement the same behavior as chromium in Python (Showing a certificate selection dialog as seen here <a href="https://github.com/chromium/chromium/blob/55f44515cd0b9e7739b434d1c62f4b7e321cd530/content/browser/ssl/ssl_client_auth_handler.cc" rel="nofollow noreferrer">ssl_client_auth_handler.cc</a>)</p>