我创建了一个名为 keystore.jks
的密钥库,它与我的 application.properties
文件位于同一目录中,现在看起来像:
# Define a custom port instead of the default 8080
server.port = 8444
# Tell Spring Security (if used) to require requests over HTTPS
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=keystore.p12
# The password used to generate the certificate
server.ssl.key-store-password=<somepassword>
# The alias mapped to the certificate
server.ssl.key-alias=tomcat
现在,如果我运行主方法启动Spring Boot应用程序,它会抛出:
Description:
The Tomcat connector configured to listen on port 8444 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8444, or configure this application to listen on another port.
端口未被使用,因此必须是配置错误吗?我不确定要改变什么。这是一个简单的SPA应用程序,Spring只提供了一个index.html和一个单一的REST端点。在这种情况下,Tomcat/Spring应该如何配置才能接受https,并在没有错误的情况下启动?
server.ssl.key-store-type
行中,小字体使用:
。yml
文件使用:
。而{file}.properties
文件使用=
。 - oakserver.ssl.key-store=backend/src/main/resources/keystore.p12
。 - cbll