com.hibegin.http.server.handler.SslChannelFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simplewebserver Show documentation
Show all versions of simplewebserver Show documentation
Simple, flexible, less dependent, more extended. Less memory footprint, can quickly build Web project.
Can quickly run embedded, Android devices
package com.hibegin.http.server.handler;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
public class SslChannelFactory {
public static SSLContext getSSLContext(File file, String password) throws Exception {
char[] passphrase = password.toCharArray();
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(file), passphrase);
SSLContext sslContext = SSLContext.getInstance("TLS");
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, passphrase);
sslContext.init(kmf.getKeyManagers(), null, null);
return sslContext;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy