1 18 package net.sf.drftpd.util; 19 20 import java.io.FileInputStream ; 21 import java.io.IOException ; 22 import java.security.GeneralSecurityException ; 23 import java.security.KeyStore ; 24 25 import javax.net.ssl.KeyManagerFactory; 26 import javax.net.ssl.SSLContext; 27 28 32 public class SSLGetContext { 33 public static SSLContext getSSLContext() 34 throws GeneralSecurityException , IOException { 35 SSLContext ctx = SSLContext.getInstance("TLS"); 36 37 KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); 38 39 KeyStore ks = KeyStore.getInstance("JKS"); 40 ks.load(new FileInputStream ("drftpd.key"), "drftpd".toCharArray()); 41 42 kmf.init(ks, "drftpd".toCharArray()); 43 44 ctx.init(kmf.getKeyManagers(), null, null); 45 return ctx; 46 } 47 } 48 | Popular Tags |