title: How to get the error string in openssl?
body: <p>I am using openssl to establish the TLS connection with the remote server.</p>
  
  <p>Here are the code snippets:</p>
  
  <pre class="lang-c prettyprint-override"><code>if ((ret = SSL_connect(c-&gt;ssl)) &lt;= 0) {
      ret = SSL_get_error(c-&gt;ssl, ret);
      if((err = ERR_get_error())) {
          SSL_load_error_strings();
          ERR_load_crypto_strings();
          CRERROR(LOGSSLUTILS, "SSL connect err code:[%lu](%s)\n", err, ERR_error_string(err, NULL));
          CRERROR(LOGSSLUTILS, "Error is %s \n",ERR_reason_error_string(err));
      }
  }
  </code></pre>
  
  <p>for some unknown reason, the ssl_connect failed and I just want to identify the reason by using the ERR_error_string, the outputs are:</p>
  
  <pre><code>SSL connect err code:[336077172] (error:14082174:lib(20):func(130):reason(372))
  
  Error: cmrSSLlInit:174 Error is (null) 
  </code></pre>
  
  <p>As you can see, I can only get the error code but cannot get the readable error string.</p>
  
  <p>How how can I get the readable error string ?</p>