Configure SSL Certificate with Spring Boot

Get SSL

Mazhar Hassan
2 min readSep 28, 2018

1.1 Free SSL

First you need to get an SSL certificate, if you can’t buy for now please use following website to generate SSL certificate for 90 days for free.

make sure you generate wildcard certificate *.expertwall.com in order to support your local, DEV, QA or production environment (Its not recommended to use free certificate on production).

Download all the files (zip) and extract it to make sure it contains

certificate.crt : Certificate generated for your domain name.
private.key: Private key of your certificate.
ca_bundle.crt: Intermediate CA (Certificate Authority)

1.2 Generate self signed certificate

Another way to get SSL certificate is to generate self-signed certificate using keytool and the rest of the steps are same.

2.1 Conversion to PKCS-12

Please note that we need to add certificate as well as private key to the keystore which is not possible in JKS format, hence certificate and private key need to be converted into .p12 format

The assumption here is that zip folder is present in the current directory of `openssl` and contains all the required files (certificate.crt, private.key, and ca_bundle.crt). Above command will generate zip/expertwall-free-PKCS-12.p12

2.2 Import PKCS-12 file format in JKS keystore

JDK would be require for this as bin folder contains a utility called keytool

Above command will generate free/expertwall-keystore.jks file with imported certificate and private key.

2.3 Import intermediate trust certificate

In order to verify your-trusted-certificate an intermediate trust certificate is also required. Following command will import ca bundle (Certificate authority) within the same keystore.

volla! your keystore is ready (contains, your SSL certificate, your private key, and certificate of CA)

Configure Spring Boot application

Open application.yml file and add following code, specify the port 8443 to run SSL port and also enter the details of keystore.

Now access your application using following url

https://localhost:8443/expertwall

--

--

Mazhar Hassan

I am learner love to explore new logics, tech and places