Author: remm Date: Wed Apr 29 11:58:09 2015 New Revision: 1676722 URL: http://svn.apache.org/r1676722 Log: Allow using SSLImplementationName configuration option with JSSE, since it turns out SSLContext cannot be extended except by using JCE. In practical terms, this allows using an alternate SSL engine implementation without having to change additional things in Tomcat.
Added: tomcat/trunk/java/org/apache/tomcat/util/net/SSLContext.java (with props) tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESSLContext.java (with props) Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractJsseEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/SSLUtil.java tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractJsseEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractJsseEndpoint.java?rev=1676722&r1=1676721&r2=1676722&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractJsseEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractJsseEndpoint.java Wed Apr 29 11:58:09 2015 @@ -21,7 +21,6 @@ import java.util.Locale; import java.util.Map; import javax.net.ssl.KeyManager; -import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSessionContext; Added: tomcat/trunk/java/org/apache/tomcat/util/net/SSLContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SSLContext.java?rev=1676722&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/SSLContext.java (added) +++ tomcat/trunk/java/org/apache/tomcat/util/net/SSLContext.java Wed Apr 29 11:58:09 2015 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tomcat.util.net; + +import java.security.KeyManagementException; +import java.security.SecureRandom; + +import javax.net.ssl.KeyManager; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSessionContext; +import javax.net.ssl.TrustManager; + +/** + * This interface is needed to override the default SSLContext class + * to allow SSL implementation pluggability without having to use JCE. With + * regular JSSE it will do nothing but delegate to the SSLContext. + */ +public interface SSLContext { + + public abstract void init(KeyManager[] kms, TrustManager[] tms, + SecureRandom sr) throws KeyManagementException; + + public abstract SSLSessionContext getServerSessionContext(); + + public abstract SSLEngine createSSLEngine(); + + public abstract SSLServerSocketFactory getServerSocketFactory(); + + public abstract SSLParameters getSupportedSSLParameters(); + +} Propchange: tomcat/trunk/java/org/apache/tomcat/util/net/SSLContext.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SSLUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SSLUtil.java?rev=1676722&r1=1676721&r2=1676722&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/SSLUtil.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/SSLUtil.java Wed Apr 29 11:58:09 2015 @@ -17,7 +17,6 @@ package org.apache.tomcat.util.net; import javax.net.ssl.KeyManager; -import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSessionContext; import javax.net.ssl.TrustManager; Added: tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESSLContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESSLContext.java?rev=1676722&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESSLContext.java (added) +++ tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESSLContext.java Wed Apr 29 11:58:09 2015 @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tomcat.util.net.jsse; + +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; + +import javax.net.ssl.KeyManager; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLServerSocketFactory; +import javax.net.ssl.SSLSessionContext; +import javax.net.ssl.TrustManager; + +import org.apache.tomcat.util.net.SSLContext; + +class JSSESSLContext implements SSLContext { + + private javax.net.ssl.SSLContext context; + JSSESSLContext(String protocol) throws NoSuchAlgorithmException { + context = javax.net.ssl.SSLContext.getInstance(protocol); + } + + @Override + public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) + throws KeyManagementException { + context.init(kms, tms, sr); + } + + @Override + public SSLSessionContext getServerSessionContext() { + return context.getServerSessionContext(); + } + + @Override + public SSLEngine createSSLEngine() { + return context.createSSLEngine(); + } + + @Override + public SSLServerSocketFactory getServerSocketFactory() { + return context.getServerSocketFactory(); + } + + @Override + public SSLParameters getSupportedSSLParameters() { + return context.getSupportedSSLParameters(); + } + +} Propchange: tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESSLContext.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java?rev=1676722&r1=1676721&r2=1676722&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java Wed Apr 29 11:58:09 2015 @@ -46,7 +46,6 @@ import javax.net.ssl.CertPathTrustManage import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.ManagerFactoryParameters; -import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSessionContext; @@ -58,6 +57,7 @@ import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.net.AbstractEndpoint; import org.apache.tomcat.util.net.Constants; +import org.apache.tomcat.util.net.SSLContext; import org.apache.tomcat.util.net.SSLHostConfig; import org.apache.tomcat.util.net.SSLUtil; import org.apache.tomcat.util.net.jsse.openssl.OpenSSLCipherConfigurationParser; @@ -107,9 +107,9 @@ public class JSSESocketFactory implement sslProtocol = defaultProtocol; } - SSLContext context; + javax.net.ssl.SSLContext context; try { - context = SSLContext.getInstance(sslProtocol); + context = javax.net.ssl.SSLContext.getInstance(sslProtocol); context.init(null, null, null); } catch (NoSuchAlgorithmException | KeyManagementException e) { // This is fatal for the connector so throw an exception to prevent @@ -376,9 +376,7 @@ public class JSSESocketFactory implement protocol = defaultProtocol; } - SSLContext context = SSLContext.getInstance(protocol); - - return context; + return new JSSESSLContext(protocol); } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org