--- java/org/apache/tomcat/websocket/WsWebSocketContainer.java (revision 1816960) +++ java/org/apache/tomcat/websocket/WsWebSocketContainer.java (working copy) @@ -76,22 +76,39 @@ implements WebSocketContainer, BackgroundProcess { /** + * Property name to set to configure the SSLEngine that will be used. The + * value should be an instance of SSLEngine. If this property is present, + * the SSL_PROTOCOLS, SSL_TRUSTSTORE*, and SSL_CONTEXT properies will be + * ignored. + */ + public static final String SSL_ENGINE_PROPERTY = + "org.apache.tomcat.websocket.SSL_ENGINE"; + /** * Property name to set to configure the value that is passed to * {@link SSLEngine#setEnabledProtocols(String[])}. The value should be a * comma separated string. + * + * @deprecated Use SSL_ENGINE_PROPERTY instead. */ + @Deprecated public static final String SSL_PROTOCOLS_PROPERTY = "org.apache.tomcat.websocket.SSL_PROTOCOLS"; + @Deprecated public static final String SSL_TRUSTSTORE_PROPERTY = "org.apache.tomcat.websocket.SSL_TRUSTSTORE"; + @Deprecated public static final String SSL_TRUSTSTORE_PWD_PROPERTY = "org.apache.tomcat.websocket.SSL_TRUSTSTORE_PWD"; - public static final String SSL_TRUSTSTORE_PWD_DEFAULT = "changeit"; + @Deprecated + public static final String SSL_TRUSTSTORE_PWD_DEFAULT = "changeit"; /** * Property name to set to configure used SSLContext. The value should be an * instance of SSLContext. If this property is present, the SSL_TRUSTSTORE* * properties are ignored. + * + * @deprecated Use SSL_ENGINE_PROPERTY instead. */ + @Deprecated public static final String SSL_CONTEXT_PROPERTY = "org.apache.tomcat.websocket.SSL_CONTEXT"; @@ -935,7 +952,18 @@ throws DeploymentException { try { - // See if a custom SSLContext has been provided + // See if a custom SSLEngine has been provided. This is the + // preferred way to configure the container. + SSLEngine engine = (SSLEngine) userProperties.get( + SSL_ENGINE_PROPERTY); + + if (null != engine) + { + return engine; + } + + // As a fallback, see if a custom SSLContext has been provided; + // the SSLContext can be used to create an SSLEngine. SSLContext sslContext = (SSLContext) userProperties.get(SSL_CONTEXT_PROPERTY); @@ -978,9 +1006,9 @@ sslContext.init(null, null, null); } } + + engine = sslContext.createSSLEngine(); - SSLEngine engine = sslContext.createSSLEngine(); - String sslProtocolsValue = (String) userProperties.get(SSL_PROTOCOLS_PROPERTY); if (sslProtocolsValue != null) {