title: How to read key from keystore in Python without SSL connection?
body: <p>Any idea how I can access key from a keystore or keyfile ( basically PKCS12 type). I do not want to create any connection. I just want to access this private key that will be on users machine, encrypt it and then send it as plain text string to the server as a param. 
  We are doing this for some kind of authentication. </p>
  
  <p>So how can I simply extract the key from keyfile? No SSL connection/certificate/etc needed.</p>
  
  <p>I am using python to implement this. </p>
  
  <p>SOL:</p>
  
  <p>I was able to extract key using pyOpenSSL using below code: </p>
  
  <pre><code>&gt;&gt;&gt; p12 = load_pkcs12(file("C:\XYZ\DistProfile.p12", "rb").read(), "passwd")  
  &gt;&gt;&gt; p12.get_certificate()
  &gt;&gt;&gt; p12.get_privatekey()
  &gt;&gt;&gt; key_pem = dump_privatekey(FILETYPE_PEM,p12.get_privatekey())
  Key_pem will have the private key 
  </code></pre>