title: Solving sslv3 alert handshake failure when trying to use a client certificate
body: <p>I'm trying to connect to a service that requires a certificate for authorization. The process is that I send the service a CSR file. The service signs the CSR and sends me a certificate that I use for connection.</p>
  
  <ol>
  <li><p>I generated the CSR by the following command line:</p>
  
  <pre><code>openssl req -new -nodes -newkey rsa:2048 -keyout cert.key -out cert.csr
  </code></pre></li>
  <li><p>I took the content of the cert.csr and sent to them. They generate the client certificate and I got a PEM file back.</p></li>
  <li><p>I now try to connect using their certificate file in SSLCERT for curl() and providing the private key from cert.key as CURLOPT_SSLKEY - (which I got at step 1). </p></li>
  <li><p>Fails with: <code>error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure</code></p></li>
  </ol>
  
  <p>What am I doing wrong in this process? </p>
  
  <p><strong>It works</strong> when I try with a received a test certificate including a private key from the service (self signed certificate). But when I use a certificate they generated from my CSR and then use my private key as key, it errors with handshake failure. </p>
  
  <p>So I know it does not have something to do with that openssl / curl doesn't support v3/TLS etc. that others when researching for a solution found out their problem was.</p>
  
  <p>Here is what I run:</p>
  
  <pre><code>  curl -i -v --request POST https://service.com/ --cert clientcert.pem --key private_key.pem --cert-type pem --tlsv1.1 --insecure
  * Connected to service.com (1xx.xxx.xxx.xx) port 443 (#0)
  * successfully set certificate verify locations:
  *   CAfile: none
    CApath: /etc/ssl/certs
  * SSLv3, TLS handshake, Client hello (1):
  * SSLv3, TLS handshake, Server hello (2):
  * SSLv3, TLS handshake, CERT (11):
  * SSLv3, TLS handshake, Server key exchange (12):
  * SSLv3, TLS handshake, Request CERT (13):
  * SSLv3, TLS handshake, Server finished (14):
  * SSLv3, TLS handshake, CERT (11):
  * SSLv3, TLS handshake, Client key exchange (16):
  * SSLv3, TLS handshake, CERT verify (15):
  * SSLv3, TLS change cipher, Client hello (1):
  * SSLv3, TLS handshake, Finished (20):
  * SSLv3, TLS alert, Server hello (2):
  * error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
  * Closing connection 0
  </code></pre>
  
  <p>Running following versions: curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3</p>