spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

How can I disable SSL v3 using the server.* properties?

Open mmladenovski opened this issue 12 years ago • 1 comments

I have been looking into disabling SSL v3 using the built-in spring boot properties (version 1.1.8.RELEASE). For example (YML config):

server:
  port: 8443
  ssl:
    key-store: "<KEY_STORE_PATH>"
    key-store-password: "<KEY_STORE_PASS>"
    key-alias: "<KEY_STORE_KEY_ALIAS>"
    key-password: "<KEY_STORE_KEY_PASSWORD>"
    protocol: "TLS"  # This is the actual default setting

Does not really disable the SSL v3 on an embedded Tomcat 8 server. With the server.ssl.protocol only sets the Tomcat sslProtocol property. However, this is not sufficient because Tomcat has two overlapping properties sslProtocol and sslEnabledProtocols (more details here: http://tomcat.apache.org/tomcat-8.0-doc/config/http.html).

In order to actually disable SSL v3 on Tomcat the sslEnabledProtocols property needs to be set in this form: TLSv1,TLSv1.1,TLSv1.2

I looked into the the server.tomcat.* settings and wasn't able to find anything related to this. Searching online (google, stackoverflow, the issues section here) also didn't help.

The only workaround I found was to move the server.port to some other port number (9000) that I don't use and add a custom tomcat connector for 8443 (based on this: http://docs.spring.io/spring-boot/docs/1.1.8.RELEASE/reference/htmlsingle/#howto-enable-multiple-connectors-in-tomcat)

@Configuration
public class TomcatConfiguration {

    @Bean
    public EmbeddedServletContainerFactory servletContainer() {
        TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
        tomcat.addAdditionalTomcatConnectors(createSslConnector());
        return tomcat;
    }

    // omitting configuration settings
    private Connector createSslConnector() {
        Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
        Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();

        connector.setScheme("https");
        connector.setSecure(true);
        connector.setPort(port);
        protocol.setSSLEnabled(true);

        protocol.setKeystoreFile(keystorePath);

        protocol.setKeystorePass(keystorePassword);
        protocol.setKeyAlias(keyAlias);
        protocol.setKeyPass(keyPassword);
        protocol.getEndpoint().setSslEnabledProtocols("TLSv1,TLSv1.1,TLSv1.2");
        return connector;
    }
}

Note the call to protocol.getEndpoint().setSslEnabledProtocols("TLSv1,TLSv1.1,TLSv1.2");.

With this workaround I have the main port, 8443 with disable SSL v3 and the other port, 9000 (not in use), with default settings (which include SSL v3).

Is there a better way to customize the existing connector and avoiding this workaround?

Thanks, Martin

mmladenovski avatar Nov 13 '14 23:11 mmladenovski

Found that latest Tomcat (8.0.15, released a week ago) disables SSL v3 by default.

Closing the question/issue.

mmladenovski avatar Nov 14 '14 16:11 mmladenovski