Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot - enable and configure SSL certificate

I have this certificates / files in order to enable SSL for my application:

certificates

I found out that this properties are needed for Spring Boot to enable HTTPS:

server.port=8089
server.ssl.enabled=true
server.ssl.key-store=src/main/resources/keystore.p12
server.ssl.key-store-password=****
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=tomcat

but this does not work. My question now would be what do I have to do in order to get it work? https://abc.lehr.co.at should be the URL.

[EDIT]

I have created my own keystore - with this I get the following exception:

java.io.IOException: Alias name tomcat does not identify a key entry
at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:596)
at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:534)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:363)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:739)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:472)
at org.apache.coyote.http11.Http11NioProtocol.start(Http11NioProtocol.java:81)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:986)

My keystore looks like this:

Keystore

Actually I don't know what to import into keystore for embedded tomcat (Spring Boot).

like image 651
quma Avatar asked Mar 28 '18 12:03

quma


People also ask

How do I enable http and https in Spring Boot?

To see both HTTP and HTTPS in action, create a simple REST controller. Build and deploy your Spring boot application. Once you application is up and running, try to open these URL's. You will get a reply from both URL's since we have enabled both HTTP and HTTPS in our Spring Boot application.

How do I add certificates to Spring Boot?

Copy the certificate file and password file that you obtained to the root directory src/main/resources/ of the Spring Boot project. Note If you have modified the directory of the Spring Boot project, you must copy the certificate and password files to the directory in which the configuration file application.


1 Answers

To enable SSL, you must provide a private key, and not a trusted certificate.

In your keystore, 'tomcat' should be listed as an alias for a privatekeyentry and not a trustedcertentry.

like image 54
Camille Vienot Avatar answered Oct 21 '22 00:10

Camille Vienot