title: How to check whether a server supports SSL with Java?
body: <p>I need to check whether a server supports SSL and the ciphers from the web server.</p>
  
  <p>I looked into SSLSocket in Java but I do not get it to work properly. </p>
  
  <p>I used the method <code>getSupportedProtocols()</code> it always gives out the same protocols for each url. Moreover I do not get the ciphers that are given from the server. I guessed <code>getEnabledCipherSuites()</code> would be the correct method </p>
  
  <pre class="lang-java prettyprint-override"><code>try {
      SSLContext ctx = SSLContext.getDefault();
      ctx.getClientSessionContext().setSessionTimeout(5); // in seconds
      SSLSocket socket = (SSLSocket) ctx.getSocketFactory().createSocket("host.com", 443);
  
      socket.setSoTimeout(5000); // in millis
      String[] result = socket.getEnabledCipherSuites();
      Arrays.sort(result);
      for (int i = 0; i &lt; result.length; i++) {
          System.out.println(result[i]); 
      }
   } catch (IOException ex) {
       System.out.println("Error!");
   }
  </code></pre>
  
  <p>How can I check that the server uses SSL? What ciphers were returned from the server? </p>