Created
July 30, 2019 06:33
-
-
Save gnh1201/841fc4368401da2ff5283324aa344ce6 to your computer and use it in GitHub Desktop.
NanoHTTPD secure connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| KeyStore keystore = KeyStore.getInstance("JKS"); | |
| InputStream keystoreStream = new FileInputStream("keystore.jks"); | |
| if (keystoreStream == null) { | |
| throw new IOException("Unable to load keystore from classpath: " + "keystore.jks"); | |
| } | |
| keystore.load(keystoreStream, "password".toCharArray()); | |
| KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); | |
| keyManagerFactory.init(keystore, "password".toCharArray()); | |
| makeSecure(NanoHTTPD.makeSSLSocketFactory(keystore, keyManagerFactory), null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment