title: ssl.SSLError: [SSL] PEM lib (_ssl.c:3837)
body: <p>Trying to connect to a server through TLS/SSL connection.</p>
  
  <p>I have searched on StackOverflow but could not find the answer 
  also to make sure certfile &amp; private key matches </p>
  
  <p>I have checked 
  <a href="https://www.sslshopper.com/certificate-key-matcher.html" rel="nofollow noreferrer">https://www.sslshopper.com/certificate-key-matcher.html</a></p>
  
  <p>and it gives me </p>
  
  <p>The certificate and private key match!</p>
  
  <p>Certificate Hash:
  3fe39d1c76d2802002741d0660dea5d7ffb6e170b5fdxxxxxxxxxx</p>
  
  <p>Key Hash:
  3fe39d1c76d2802002741d0660dea5d7ffb6e170b5fdxxxxxxxxxx</p>
  
  <p>I tried .crt &amp; .pem &amp; did not work </p>
  
  <p>the error </p>
  
  <pre><code> context.load_cert_chain(certfile=client_cert, keyfile=clients_key, 
   password=None)
   ssl.SSLError: [SSL] PEM lib (_ssl.c:3837)
  </code></pre>
  
  <p>code:-</p>
  
  <pre><code>def tlstest():
  
  
       hostAddress = 'x'
       hostPort = xxxx
       serverHostName = 'x.com'
  
        client_cert = 'D:\ssl\client.pem'
        clients_key = 'D:\ssl\clientKey.pem'
  
        context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
  
        context.load_cert_chain(certfile=client_cert, keyfile=clients_key,
                          password=None)
  
        context.verify_mode = ssl.CERT_REQUIRED
  </code></pre>