Skip to content

Instantly share code, notes, and snippets.

@patoi
Forked from joshlong/gist:10964238
Created July 26, 2014 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patoi/0b91bf385b1ed2e1ac60 to your computer and use it in GitHub Desktop.
Save patoi/0b91bf385b1ed2e1ac60 to your computer and use it in GitHub Desktop.
@Bean
EmbeddedServletContainerCustomizer containerCustomizer(
@Value("${keystore.file}") Resource keystoreFile,
@Value("${keystore.pass}") String keystorePass) throws Exception {
String absoluteKeystoreFile = keystoreFile.getFile().getAbsolutePath();
return (ConfigurableEmbeddedServletContainer container) -> {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(
(connector) -> {
connector.setPort(8443);
connector.setSecure(true);
connector.setScheme("https");
Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
proto.setSSLEnabled(true);
proto.setKeystoreFile(absoluteKeystoreFile);
proto.setKeystorePass(keystorePass);
proto.setKeystoreType("PKCS12");
proto.setKeyAlias("tomcat");
}
);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment