I am creating a simple HttpsServer:
public void start(String a_sAddress, int a_nPort, HashMap<String, HttpHandler> a_mapString2HttpHandler) throws IOException {
// skipped several irrelevant lines...
try {
// Install the all-trusting trust manager
final SSLContext sslContext = SSLContext.getInstance( "SSL" );
sslContext.init( null, trustAllCerts, new java.security.SecureRandom() );
// Init a configuration with our SSL context
HttpsConfigurator configurator = new HttpsConfigurator(sslContext);
HttpsServer server = HttpsServer.create(new InetSocketAddress(8000), a_nPort);
server.setHttpsConfigurator(configurator);
a_mapString2HttpHandler.forEach((path, handler) -> {
System.out.println("Register an HttpsHandler for " + path);
server.createContext(path, handler);
});
server.setExecutor(null); // creates a default executor
server.start();
}
catch (KeyManagementException e) {
System.out.println("HttpsRequest - KeyManagementException");
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
System.out.println("HttpsRequest - NoSuchAlgorithmException");
e.printStackTrace();
}
}
As you can see, I use SSLContext.getInstance( "SSL" ); to support SSL. Is there a way I can support more than one protocol? for example SSL and TLS?