我想将本地主机从超文本传输协议转换为安全套接字层超文本传输协议。因此,我已经在我的spring boot项目中添加了一个密钥库,并像这样配置了application.properties:
信息
但是我在chrome中看到一个错误:
localhost uses an unsupported protocol.
ERR__VERSION_OR_CIPHER_MISMATCH
注意:我没有对任何Java文件做任何更改。
答案 0 :(得分:0)
当我遇到此问题时,可以通过bean
来解决,如下所示。希望这对您有帮助
@Configuration
class CustomConfiguration {
@Bean
public EmbeddedServletContainerFactory servletContainer() {
final int port = 8443;
final String keystoreFile = "/path/to/keystore"
final String keystorePass = "keystore-password"
final String keystoreType = "pkcs12"
final String keystoreProvider = "SunJSSE"
final String keystoreAlias = "tomcat"
TomcatEmbeddedServletContainerFactory factory =
new TomcatEmbeddedServletContainerFactory(this.port);
factory.addConnectorCustomizers( new TomcatConnectorCustomizer() {
void customize(Connector con) {
Http11NioProtocol proto = (Http11NioProtocol) con.getProtocolHandler();
proto.setSSLEnabled(true);
con.setScheme("https");
con.setSecure(true);
proto.setKeystoreFile(keystoreFile);
proto.setKeystorePass(keystorePass);
proto.setKeystoreType(keystoreType);
proto.setProperty("keystoreProvider", keystoreProvider);
proto.setKeyAlias(keystoreAlias);
}
});
return factory;
}
}
还要确保您使用-storetype pkcs12
而不是-storepass pkcs12
调用keytool