Code example for SSLContext

Methods: createSSLEngine

0
   * @throws IOException thrown if and IO error occurred while loading 
   * the server keystore. 
   */ 
  public SSLEngine createSSLEngine()
    throws GeneralSecurityException, IOException { 
    SSLEngine sslEngine = context.createSSLEngine();
    if (mode == Mode.CLIENT) {
      sslEngine.setUseClientMode(true);
    } else { 
      sslEngine.setUseClientMode(false);
      sslEngine.setNeedClientAuth(requireClientCert);
    } 
    return sslEngine;
  } 
 
  /** 
   * Returns a configured SSLServerSocketFactory. 
   * 
   * @return the configured SSLSocketFactory. 
   * @throws GeneralSecurityException thrown if the SSLSocketFactory could not 
   * be initialized.