- cmd 切换 jdk/bin 目录
- 执行
>keytool -genkeypair -alias selfsigned_localhost_sslserver -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore ebininfosoft-ssl-key.p12 -validity 3650
- jdk/bin 下
ebininfosoft-ssl-key.p12
文件丢到 resources 下
- 配置文件
server:
port: 9064 # https
http:
port: 9061 # http
ssl:
key-store-type: PKCS12
key-store: classpath:ebininfosoft-ssl-key.p12
enabled: true
key-store-password: hgyairr # 密码
@Configuration
public class TomcatHttp2HttpsConfig {
@Value("${server.http.port}")
private int httpPort;
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
return tomcat;
}
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(httpPort);
return connector;
}
}