HttpsParameters Cant be recognised

I want to secure my http request ,Im using something like http://123.456.789.123:1234 and I want secure it. I create a keystore.csr carets.jks server.cer and keystore.jks with the java keytool after that I implement my code, but it can't read HttpsParameters

String alias = "alias";

char [] storepass = "changeit".toCharArray();

String keystoreName = "c:\\keystore.jks";

FileInputStream in = new FileInputStream(keystoreName);

KeyStore keystore = KeyStore.getInstance("JKS");

keystore.load(in, storepass);

Certificate cert = keystore.getCertificate(alias);

Log.debug("the certification is here : " + cert);

KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");

char [] keypass = "changeit".toCharArray();

kmf.init(keystore, keypass);

TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");


HttpsServer server = HttpsServer.create(new InetSocketAddress(port), 0);

SSLContext sslContext = SSLContext.getInstance("SSL");

sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

server.setHttpsConfigurator(new HttpsConfigurator(sslContext)...

Read More »

By: StackOverFlow - Tuesday, 6 November

Related Posts