对于基于Spring Boot的应用程序,我已经在application.properties中配置了ssl属性,请查看我的配置:
server.port=8443
server.ssl.key-alias=tomcat
server.ssl.key-password=123456
server.ssl.key-store=classpath:key.p12
server.ssl.key-store-provider=SunJSSE
server.ssl.key-store-type=pkcs12
我已经在Application.class中添加了连接,如下:
@Bean
public EmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
final TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addAdditionalTomcatConnectors(this.createConnection());
return factory;
}
private Connector createConnection() {
final String protocol = "org.apache.coyote.http11.Http11NioProtocol";
final Connector connector = new Connector(protocol);
connector.setScheme("http");
connector.setPort(9090);
connector.setRedirectPort(8443);
return connector;
}
但是当我尝试以下操作时:
http://127.0.0.1:9090/
跳转到
https://127.0.0.1:8443/
未执行。谁遇到过类似的问题?
TomcatEmbeddedServletContainerFactory
应该在配置类中作为一个 bean 暴露出来。 - Andy WilkinsonPOST
请求不会被重定向。 - nurgasemetey