繁体   English   中英

https 后的 Spring 启动:配置为侦听端口 8444 的 Tomcat 连接器启动失败。

[英]Spring boot after https: The Tomcat connector configured to listen on port 8444 failed to start.

我按照指南在 Spring Boot 中启用 https。 该应用程序事先在https://localhost:8080 上工作

我创建了一个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

现在,如果我运行 main 方法来启动 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,并且启动没有错误?

我也有同样的问题,并且能够修复它。 我的问题是生成keystore.p12文件。

如果您有证书文件和私钥文件,则可以使用以下命令生成keystore.p12文件。

openssl pkcs12 -export -in <mycert.crt> -inkey <mykey.key> -out keystore.p12 -name <alias>

系统会提示您输入密码,您可以在那里输入您喜欢的密码。 生成密钥库文件后,将其复制到.jar文件所在的目录。

以下是一个工作示例配置。

server.port=8443
security.require-ssl=true
server.ssl.key-store-type=PKCS12
server.ssl.key-store=file:keystore.p12
server.ssl.key-store-password=<password>
server.ssl.key-alias=<alias>

如果密钥存储文件路径file:keystore.p12与可执行.jar文件位于同一目录中,请注意它。

我通过使用以下配置解决了同样的问题

# Define a custom port instead of the default 8080
server.port=8443
# 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=src/main/resources/keystore.p12
# The password used to generate the certificate
server.ssl.key-store-password=root0

我删除了别名,它工作得很好。 “您可能不需要密钥别名,因为只有一个密钥条目”来自TOMCAT SSL 错误:别名不能识别密钥条目

从 Spring Boot 2.0 及更高版本开始,您可以忽略此属性。

security.require-ssl=true

要启用 SSL,请在 application.properties 中使用以下配置

用于密钥库的格式

server.ssl.key-store-type=JKS

包含证书的密钥库的路径

server.ssl.key-store=classpath:somecert.jks

用于生成证书的密码

server.ssl.key-store-password=密码

映射到证书的别名

server.ssl.key-alias=alias_name

注意:server.ssl.key-store 指的是密钥库位置。 使用类路径前缀,如果它存在于 src/main/resources 中。 否则使用,file:/some/location。

我也遇到了同样的问题,但在我的情况下,密钥库文件的文件路径(在 application.properties 中)在 Linux 上不正确并导致此错误消息。

我有同样的问题。 对我来说server.ssl.key-alias被设置为错误的键。 因此,听起来application.properties中的某些服务器错误配置会导致出现此错误消息。

我遵循了在Spring Boot中启用https的指南。 该应用程序之前在https:// localhost:8080上工作

我已经创建了一个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

现在,如果我运行main方法来启动spring boot app,它会抛出:

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,并且启动时不会出现错误?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM