title: openssl SSL_Connect with err 2
body: <p>Iam a new member into this forum. </p>
  
  <p>Issue: </p>
  
  <p>I have to integrate openssl in my project.project is implemented with gsoap. </p>
  
  <p>in "r = SSL_connect(soap->ssl)) &lt;= 0)" 
  SSL_connect call is unable to make a connection to the server.Both server and client are in local host </p>
  
  <p>I see server is ready to accept the connections, as I see below connection established with netstat command: </p>
  
  <p>TCP    cspxppgudepu:15000     cspxppgudepu.com:0  LISTENING 
  TCP    cspxppgudepu:15000     localhost:2864         ESTABLISHED </p>
  
  <p>Above 15000 port is for server. </p>
  
  <p>Below is client connection: 
   TCP    cspxppgudepu:16000     cspxppgudepu.com:0  LISTENING </p>
  
  <p>But SSL_connect is unable to connect.It is always failing with return code -1 &amp; err 2. </p>
  
  <p>With out SSL connection,simple TCP conection, both ends are able to connect and communicate. Below network configuration  settings for without SSL
   
                   
                    </p>
  
  <p>My network configuration settings for with openssl: </p>
  
  <pre><code>    &lt;NetworkConfig&gt; 
              &lt;Server Location="https://127.0.0.1:15000" /&gt; 
              &lt;Client Location="https://127.0.0.1:16000" /&gt; 
  </code></pre>
  
  <p>I have taken both client &amp; server authentication to false.</p>
  
  <p>Thanks in advance. 
  Pradeep Reddy. </p>
  
  <hr>
  
  <p>An update,</p>
  
  <p>SSL_connect is failing with SSL_ERROR_WANT_READ.I understand that client is waiting on server to write some data.But I dont understand what to change code in server side.</p>
  
  <p>please let me know, how to go from this.</p>
  
  <hr>
  
  <p>SSL communcation is working fine now if I give root certificate cacert.pem on both server and client and authentication is set to true.Instead of giving the same root certificate cacert.pem I have given clientcert.pem and servercert.pem in soap_ssl_client_context() and soap_ssl_server_context() calls respectively. 
  This time Handshake is failed with below error at client side:"error:14090086:lib(20):func(144):reason(134)" 
  and server side "error:14094418:lib(20):func(148):reason(1048)" </p>
  
  <p>But both client certificate and server certificate are generated from root certificate "cacert.pem" below comands. </p>
  
  <p>Command:openssl x509 -req -in clientreq.pem -sha1 -extensions usr_cert -CA root.pem -CAkey root.pem -CAcreateserial -out clientcert.pem -days 1095 
  and 
  Command:openssl x509 -req -in serverreq.pem -sha1 -extensions usr_cert -CA root.pem -CAkey root.pem -CAcreateserial -out servercert.pem -days 1095 
  error I understood as "error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca".
  But both certificates are from same root CA cacertpem. Please provide if you have any fix.
  I could not edit the post, so posting the answer.
  Thanks,
  Pradeep. </p>