https之后的春季启动:配置为在端口8444上进行侦听的Tomcat连接器无法启动. [英] Spring boot after https: The Tomcat connector configured to listen on port 8444 failed to start.

查看:540
本文介绍了https之后的春季启动:配置为在端口8444上进行侦听的Tomcat连接器无法启动.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I followed a guide to enable https in Spring Boot. The application was beforehand working on https://localhost:8080

我已经创建了一个keystore.jks,它与我的application.properties在同一目录中,现在看起来像:

I've created a keystore.jks which is in the same directory as my application.properties, which now looks like:

# 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应用程序,它将抛出:

Now, if I run the main method to start the spring boot app, it throws:

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.

该端口未使用,因此必须配置错误吗?

The port isn't in use, so it must be misconfiguration?

我不确定该更改什么.这是一个简单的SPA应用程序,Spring仅提供index.html并具有单个REST端点.在这种情况下,应如何将tomcat/spring配置为接受https,并且启动时不会出现错误?

I'm unsure of what to change. It's a simple SPA app, Spring just serves an index.html and has a single REST endpoint. How should tomcat/spring be configured to accept https in this case, and start up without errors?

推荐答案

我也遇到了同样的问题,并且能够解决它.我的问题是生成keystore.p12文件.

I too had the same problem and was able to fix it. My problem was generating the keystore.p12 file.

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

If you have a certificate file and private key file, you can generatekeystore.p12 file using following command.

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

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

You will be prompted for a password,there you can enter a password you like. Once the keystore file is generated copy it to the directory where your .jar file exist.

以下是一个有效的示例配置.

Following is a working example configuration.

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>

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

Note the key store file path file:keystore.p12 if it is going to reside in the same directory as the executable .jar file.

这篇关于https之后的春季启动:配置为在端口8444上进行侦听的Tomcat连接器无法启动.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆