◎위챗 : speedseoul
http://mainia.tistory.com/717
java -Djavax.net.ssl.keyStore=keyStoreFile -Djavax.net.ssl.keyStorePassword=keystorePassword Server
System.setProperty("javax.net.ssl.keyStore", 'keystoreFile');
System.setProperty("javax.net.ssl.keyStorePassword", 'keystorePassword ');
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream("keystoreFile"), "keystorePassword".toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
kmf.init(ks, "keystorePassword".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
tmf.init(ks);/
SSLContext sc = SSLContext.getInstance("TLS");
TrustManager[] trustManagers = tmf.getTrustManagers();
sc.init(kmf.getKeyManagers(), trustManagers, null);
SSLServerSocketFactory ssf = sc.getServerSocketFactory();
SSLServerSocket s = (SSLServerSocket) ssf.createServerSocket(serverport);
SSLSocket c = (SSLSocket) s.accept();
SSLServerSocketFactory ssf = sc.getSocketFactory();
SSLSocket s = (SSLSocket) ssf.createSocket(serverip, serverport);
s.startHandshake();
http://alvinalexander.com/java/jwarehouse/android/tests/CoreTests/android/core/SSLSocketTest.java.shtml
protected SSLSocketFactory createSSLSocketFactory() {
InputStream in = null;
try {
KeyStore localTrustStore = KeyStore.getInstance("BKS");
in = getResources().openRawResource(R.raw.ssl_keystore);
localTrustStore.load(in, "keystore_password".toCharArray());
return new SSLSocketFactory(localTrustStore);
} catch (Exception e) {
throw new RuntimeException("Could not create SSLSocketFactory", e);
} finally {
if ( in != null ) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}