title: SSL Handshake Timeout
body: <p>I have 2 client authentication certificates issued by the same certificate authority. One of them enables me to connect to a HTTPS webservice, but the other does not when I use code similar to the following:</p>
  
  <pre><code>HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create( endPointUrl );
  X509Store store = new X509Store( StoreName.My, StoreLocation.LocalMachine );
  store.Open( OpenFlags.MaxAllowed );
  X509CertificateCollection col = (X509CertificateCollection)store.Certificates.Find( X509FindType.FindBySerialNumber, certificateSerialNumber, true );
  httpWebRequest.ClientCertificates.Add( col[0] );
  httpWebRequest.Method = "POST";
  httpWebRequest.ContentType = contentType;
  httpWebRequest.KeepAlive = false;
  httpWebRequest.Timeout = 3000;
  httpWebRequest.ContentLength = message.Length;
  httpRequestStream = httpWebRequest.GetRequestStream();
  </code></pre>
  
  <p>When attempting to get the request stream, I get an InvalidOperationException with the message "The operation has timed out".</p>
  
  <p>I've used System.Net.trace when attempting to connect with the certificate that fails and the log shows a connection timeout before "Attempting to restart the session using the user-provided certificate" and just after the first InitializeSecurityContext.</p>
  
  <p>Wireshark show the following:</p>
  
  <pre><code>"TCP","j-link &gt; https [SYN] Seq=0 Win=65535 Len=0 MSS=1260 SACK_PERM=1"
  "TCP","https &gt; j-link [SYN, ACK] Seq=0 Ack=1 Win=32768 Len=0 MSS=1380"
  "TCP","j-link &gt; https [ACK] Seq=1 Ack=1 Win=65535 Len=0"
  "TLSv1","Client Hello"
  "TLSv1","Server Hello"
  "TCP","[TCP segment of a reassembled PDU]"
  "TCP","j-link &gt; https [ACK] Seq=78 Ack=2521 Win=65535 Len=0"
  "TLSv1","Certificate, Certificate Request, Server Hello Done"
  "TCP","j-link &gt; https [ACK] Seq=78 Ack=3187 Win=64869 Len=0"
  "TCP","j-link &gt; https [FIN, ACK] Seq=78 Ack=3187 Win=64869 Len=0"
  "TCP","https &gt; j-link [ACK] Seq=3187 Ack=79 Win=32768 Len=0"
  "TLSv1","Alert (Level: Warning, Description: Close Notify)"
  "TCP","j-link &gt; https [RST, ACK] Seq=79 Ack=3194 Win=0 Len=0"
  </code></pre>
  
  <p>I can connect using OpenSSL from the command line using both certificates after exporting them and converting them to the PEM format.</p>
  
  <p>Any suggestions would be greatly appreciated.</p>