Author: sebb Date: Thu Mar 17 01:24:48 2011 New Revision: 1082368 URL: http://svn.apache.org/viewvc?rev=1082368&view=rev Log: Use new SSLContextUtils to create the context
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java?rev=1082368&r1=1082367&r2=1082368&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPSClient.java Thu Mar 17 01:24:48 2011 @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.Socket; -import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import javax.net.ssl.KeyManager; @@ -33,6 +32,8 @@ import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; +import org.apache.commons.net.util.SSLContextUtils; + /** * FTP over SSL processing. If desired, the JVM property -Djavax.net.debug=all can be used to * see wire-level SSL details. @@ -205,23 +206,7 @@ public class FTPSClient extends FTPClien */ private void initSslContext() throws IOException { if(context == null) { - try { - context = SSLContext.getInstance(protocol); - KeyManager keyMgr = getKeyManager(); - TrustManager trustMgr = getTrustManager(); - context.init( - keyMgr == null ? null : new KeyManager[] { keyMgr } , - trustMgr == null ? null : new TrustManager[] { trustMgr } , - null); // use default random implementation - } catch (KeyManagementException e) { - IOException ioe = new IOException("Could not initialize SSL context"); - ioe.initCause(e); - throw ioe; - } catch (NoSuchAlgorithmException e) { - IOException ioe = new IOException("Could not initialize SSL context"); - ioe.initCause(e); - throw ioe; - } + context = SSLContextUtils.createSSLContext(protocol, getKeyManager(), getTrustManager()); } }