簡體   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