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

cbll :

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

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

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?

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?

Johna :

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

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>

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>

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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=437162&siteId=1