-
-
Save patoi/0b91bf385b1ed2e1ac60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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