title: SSL socket php code needs to be converted to Java
body: <p>I have a Pem file that I use with this php code to connect to a c++ SSL server, but now I need this php code written in Java</p>
  
  <pre><code>$ctx = stream_context_create();
  
  stream_context_set_option($ctx, 'ssl', 'local_cert', 'cert.pem');
  
  stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);
  
  $fp = stream_socket_client('ssl://serverURL', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
  
  if (!$fp) {
  
      print "Failed to connect $err $errstr\n";
      return;
  }
  </code></pre>
  
  <p>Any ideas how to read in the cert.pem file in Java and then establish the SSL socket?</p>
  
  <p>Thank you!</p>