Skip to content

Commit

Permalink
Move sslProtocol to SSLHostConfig
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1678141 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed May 7, 2015
1 parent a5cb7cc commit 99163fc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 34 deletions.
3 changes: 0 additions & 3 deletions java/org/apache/coyote/http11/AbstractHttp11JsseProtocol.java
Expand Up @@ -25,9 +25,6 @@ public AbstractHttp11JsseProtocol(AbstractEndpoint<S> endpoint) {
super(endpoint); super(endpoint);
} }


public String getSslProtocol() { return getEndpoint().getSslProtocol();}
public void setSslProtocol(String s) { getEndpoint().setSslProtocol(s);}

public void setSessionCacheSize(String s){getEndpoint().setSessionCacheSize(s);} public void setSessionCacheSize(String s){getEndpoint().setSessionCacheSize(s);}
public String getSessionCacheSize(){ return getEndpoint().getSessionCacheSize();} public String getSessionCacheSize(){ return getEndpoint().getSessionCacheSize();}


Expand Down
6 changes: 6 additions & 0 deletions java/org/apache/coyote/http11/AbstractHttp11Protocol.java
Expand Up @@ -506,6 +506,12 @@ public void setTruststoreProvider(String truststoreProvider){
} }




public void setSslProtocol(String sslProtocol) {
registerDefaultSSLHostConfig();
defaultSSLHostConfig.setSslProtocol(sslProtocol);
}


// ------------------------------------------------------------- Common code // ------------------------------------------------------------- Common code


// Common configuration required for all new HTTP11 processors // Common configuration required for all new HTTP11 processors
Expand Down
4 changes: 0 additions & 4 deletions java/org/apache/tomcat/util/net/AbstractEndpoint.java
Expand Up @@ -963,10 +963,6 @@ public void setSslImplementationName(String s) {
this.sslImplementationName = s; this.sslImplementationName = s;
} }


private String sslProtocol = "TLS";
public String getSslProtocol() { return sslProtocol;}
public void setSslProtocol(String s) { sslProtocol = s;}

private String sessionCacheSize = null; private String sessionCacheSize = null;
public String getSessionCacheSize() { return sessionCacheSize;} public String getSessionCacheSize() { return sessionCacheSize;}
public void setSessionCacheSize(String s) { sessionCacheSize = s;} public void setSessionCacheSize(String s) { sessionCacheSize = s;}
Expand Down
12 changes: 12 additions & 0 deletions java/org/apache/tomcat/util/net/SSLHostConfig.java
Expand Up @@ -64,6 +64,7 @@ public class SSLHostConfig {
private String certificateKeystoreProvider = System.getProperty("javax.net.ssl.keyStoreProvider"); private String certificateKeystoreProvider = System.getProperty("javax.net.ssl.keyStoreProvider");
private String certificateKeystoreType = System.getProperty("javax.net.ssl.keyStoreType"); private String certificateKeystoreType = System.getProperty("javax.net.ssl.keyStoreType");
private String keyManagerAlgorithm = KeyManagerFactory.getDefaultAlgorithm(); private String keyManagerAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
private String sslProtocol = "TLS";
private String trustManagerClassName; private String trustManagerClassName;
private String truststoreAlgorithm = TrustManagerFactory.getDefaultAlgorithm(); private String truststoreAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
private String truststoreFile = System.getProperty("javax.net.ssl.trustStore"); private String truststoreFile = System.getProperty("javax.net.ssl.trustStore");
Expand Down Expand Up @@ -315,6 +316,17 @@ public String getKeyManagerAlgorithm() {
} }




public void setSslProtocol(String sslProtocol) {
setProperty("sslProtocol", Type.JSSE);
this.sslProtocol = sslProtocol;
}


public String getSslProtocol() {
return sslProtocol;
}


public void setTrustManagerClassName(String trustManagerClassName) { public void setTrustManagerClassName(String trustManagerClassName) {
setProperty("trustManagerClassName", Type.JSSE); setProperty("trustManagerClassName", Type.JSSE);
this.trustManagerClassName = trustManagerClassName; this.trustManagerClassName = trustManagerClassName;
Expand Down
25 changes: 6 additions & 19 deletions java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
Expand Up @@ -81,8 +81,6 @@ public class JSSESocketFactory implements SSLUtil {
private static final StringManager sm = private static final StringManager sm =
StringManager.getManager("org.apache.tomcat.util.net.jsse.res"); StringManager.getManager("org.apache.tomcat.util.net.jsse.res");


// Defaults - made public where re-used
private static final String defaultProtocol = "TLS";
private static final int defaultSessionCacheSize = 0; private static final int defaultSessionCacheSize = 0;
private static final int defaultSessionTimeout = 86400; private static final int defaultSessionTimeout = 86400;


Expand All @@ -96,15 +94,10 @@ public JSSESocketFactory (AbstractEndpoint<?> endpoint, SSLHostConfig sslHostCon
this.endpoint = endpoint; this.endpoint = endpoint;
this.sslHostConfig = sslHostConfig; this.sslHostConfig = sslHostConfig;


String sslProtocol = endpoint.getSslProtocol(); SSLContext context;
if (sslProtocol == null) {
sslProtocol = defaultProtocol;
}

javax.net.ssl.SSLContext context;
try { try {
context = javax.net.ssl.SSLContext.getInstance(sslProtocol); context = createSSLContext();
context.init(null, null, null); context.init(null, null, null);
} catch (NoSuchAlgorithmException | KeyManagementException e) { } catch (NoSuchAlgorithmException | KeyManagementException e) {
// This is fatal for the connector so throw an exception to prevent // This is fatal for the connector so throw an exception to prevent
// it from starting // it from starting
Expand Down Expand Up @@ -268,16 +261,10 @@ private KeyStore getStore(String type, String provider, String path,
return ks; return ks;
} }


@Override
public SSLContext createSSLContext() throws Exception {

// SSL protocol variant (e.g., TLS, SSL v3, etc.)
String protocol = endpoint.getSslProtocol();
if (protocol == null) {
protocol = defaultProtocol;
}


return new JSSESSLContext(protocol); @Override
public SSLContext createSSLContext() throws NoSuchAlgorithmException {
return new JSSESSLContext(sslHostConfig.getSslProtocol());
} }




Expand Down
23 changes: 15 additions & 8 deletions webapps/docs/config/http.xml
Expand Up @@ -1197,6 +1197,18 @@
used.</p> used.</p>
</attribute> </attribute>


<attribute name="sslProtocol" required="false">
<p>JSSE only.</p>
<p>The the SSL protocol(s) to use (a single value may enable multiple
protocols - see the JVM documentation for details). If not specified, the
default is <code>TLS</code>. The permitted values may be obtained from the
JVM documentation for the allowed values for algorithm when creating an
<code>SSLContext</code> instance e.g.
<a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext">
Oracle Java 7</a>. Note: There is overlap between this attribute and
<code>protocols</code>.</p>
</attribute>

<attribute name="trustManagerClassName" required="false"> <attribute name="trustManagerClassName" required="false">
<p>JSSE only.</p> <p>JSSE only.</p>
<p>The name of a custom trust manager class to use to validate client <p>The name of a custom trust manager class to use to validate client
Expand Down Expand Up @@ -1349,14 +1361,9 @@
</attribute> </attribute>


<attribute name="sslProtocol" required="false"> <attribute name="sslProtocol" required="false">
<p>The the SSL protocol(s) to use (a single value may enable multiple <p>This is an alias for the <code>sslProtocol</code> attribute of the
protocols - see the JVM documentation for details). If not specified, the default <a href="#SSL_Support_-_SSLHostConfig">SSLHostConfig</a>
default is <code>TLS</code>. The permitted values may be obtained from the element.</p>
JVM documentation for the allowed values for algorithm when creating an
<code>SSLContext</code> instance e.g.
<a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SSLContext">
Oracle Java 7</a>. Note: There is overlap between this attribute and
<code>sslEnabledProtocols</code>.</p>
</attribute> </attribute>


<attribute name="trustManagerClassName" required="false"> <attribute name="trustManagerClassName" required="false">
Expand Down

0 comments on commit 99163fc

Please sign in to comment.