Enable SSL In Quarkus Application

Enabling the Secure Socket Layer(SSL) in an application prevents an attacker from stealing sensitive information. Enabling SSL helps secure the connection between the client and the application. In this article, we will learn how to enable SSL in a Quarkus application.

Two secure the communication with the SSL connection, we need a certificate and an associated key file. We can provide these information in the forma of a keystore.

Generate SSL certification

We can use the keygen tool to generate the keystore. Let’s navigate inside the src/main/resources folder of the Quarkus application and run the below command.

keytool -genkey -keyalg RSA -alias selfsigned \
-keystore keystore.jks -storepass password \
-validity 360 -keysize 2048

The tool asks for some generic information that helps the keytool to generate the keystore.

Once we enter the details and command execution is completed, a keystore.jks file is generated as shown below.

quarkus ssl enable

Enable SSL

Quarkus provides following configuration properties to enable SSL. We can add these configuration details inside the application.properties file under the src/main/resources/ folder.

quarkus.http.ssl-port=8443
quarkus.http.ssl.certificate.key-store-file=keystore.jks
quarkus.http.ssl.certificate.key-store-file-type=jks
quarkus.http.ssl.certificate.key-store-password=password

The quarkus.http.ssl-port property sets the SSL port to 8443.

We also can specify the SSL details like SSL keystore location(relative to the src/main/resources folder), key-store file type and the password for the keystore as shown above.

Start the Quarkus application, and we should be able to verify the SSL enabled connection as shown below.

quarkus ssl enable

Conclusion

In this article, we learned how to enable SSL in Quarkus application.

Enable SSL In Quarkus Application

Leave a Reply

Scroll to top

Discover more from ASB Notebook

Subscribe now to keep reading and get access to the full archive.

Continue reading