Я сгенерировал самозаверяющий сертификат, используя keytool
. Я добавил в свою папку ресурсов.
Внутри моего application.properties
я добавил
security.require-ssl=true
# The format used for the keystore
server.ssl.key-store-type=PKCS12
# The path to the keystore containing the certificate
server.ssl.key-store=classpath:keystore.p12
# The password used to generate the certificate
server.ssl.key-store-password=
# The alias mapped to the certificate
server.ssl.key-alias=tomcat
Мой конфигурационный файл:
@Bean
public EmbeddedServletContainerFactory servletContainer() {
EmbeddedServletContainerFactory tomcat = new EmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(getHttpConnector());
return tomcat;
}
Но я все еще не могу получить доступ к своему приложению с помощью https?