title: Check Server security protocol using openssl
body: <p>I have an framework application which connects to different servers depending on how it is used. For https connections openssl is used. My problem is, that I need to know if the server I am connecting to is using SSL or TLS, so I can create the right SSL context. Currently if I use the wrong context trying to establish a connection times out. </p>
  
  <p>For TLS I use:</p>
  
  <pre><code>SSL_CTX *sslContext = SSL_CTX_new(TLSv1_client_method());
  </code></pre>
  
  <p>For SSL I use:</p>
  
  <pre><code>SSL_CTX *sslContext = SSL_CTX_new(SSLv23_client_method());
  </code></pre>
  
  <p>So is there a way to know which protocol a server is running before establishing a connection?</p>
  
  <p>Edit: So as I understand it now it should work either way, since the <code>SSLv23_client_method()</code> also contains the TLS protocol. So the question is why does it not? What could be the reason for a timeout with one client method but not the other?  </p>