title: How to make a TLS request using a smartcard with python?
body: <p>I have tried to use python library  "requests" to communicate with a website protected by a smartcard. It means a strong authentification in SSL : you must give a client side certificate (cert and private key).</p>
  
  <p>As I am using a smartcard, I cannot read the private key (only the modulus) that is a normal protection. I can read the smartcard with the python library PyKCS11 : all certificate, public key and modulus of private key once given the pin code. </p>
  
  <p>How to mix both requests and PyKCS11 ?<br>
  How to make a SSL request with a client side certificate in a smartcard ? </p>
  
  <p>EDIT 2017/08/04</p>
  
  <p>On my Mac : </p>
  
  <ul>
  <li>brew install openssl </li>
  <li>brew install opensc  </li>
  <li>brew install engine_pkcs11</li>
  <li>openssl
  
  <ul>
  <li>engine dynamic -pre SO_PATH:/usr/local/Cellar/engine_pkcs11/0.1.8/lib/engines/engine_pkcs11.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -pre MODULE_PATH:/usr/local/lib/(my specific Pkcs11 lib).dylib
  
  <ul>
  <li>Loaded: (pkcs11) pkcs11 engine</li>
  </ul></li>
  <li>s_client -engine pkcs11 -key '(slot):(id)' -keyform engine -cert 'pem.cer' -connect (host):443 -state -debug
  
  <ul>
  <li>SSL handshake ok</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>My problem now is that pyOpenSSl do not have a function in the API to select an engine (like pkcs11). So I am stopped. I cannot use python.</p>