Quarkus Security : Securing rest api with HTTPS

Share on:

Quarkus is no doubt one the most super-fast framework for developing the Cloud Native java application.

If you have worked with Spring Boot application than I think you are gonna love Quarkus because of its simplicity, super-fast boot time and extremely low memory usage.

For the beginner, I would highly recommend going through my article

All right now what we are gonna do

  1. Create a simple REST endpoint application using JAVA, JAX-RS, and Quarks
  2. Securing the REST endpoint with HTTPS

Enough with the intro but the next questions comes into our mind “Why we need to secure our REST endpoint?"

Because we want to authorized and secure transactions and HTTPS makes this happen. Speaking of HTTPS, Transport Layer Security (TLS) is the official name for HTTPS.

The primary goal of TLS is to secure, ensure privacy and data integrity between two entities.

In this tutorial, we are going to enable the HTTPS using self-signed certificate.

Let’s do some coding!

Create Quarkus application

Maven: You can bootstrap your project with

1mvn io.quarkus:quarkus-maven-plugin:1.3.1.Final:create \
2    -DprojectGroupId=my-groupId \
3    -DprojectArtifactId=my-artifactId \
4    -DprojectVersion=my-version \
5    -DclassName="com.jhooq.JhooqHelloWorld"

Gradle: Head over to Code.Quarkus.io and fill in the following bootstrap configuration

  • [table id=quarkus-gradle-bootstrap /]

After that click on the “Generate Your Application

Download the project zip file and import it inside your favorite IDE e.g Intellij, Eclipse.

“Hello World” - REST Endpoint java class
 1import javax.ws.rs.GET;
 2import javax.ws.rs.Path;
 3import javax.ws.rs.Produces;
 4import javax.ws.rs.core.MediaType;
 7public class ExampleResource {
 9    @GET
10    @Produces(MediaType.TEXT_PLAIN)
11    public String customerOrder() {
12        return "hello world ! From Jhooq";
13    }

HTTPS: Securing connection with SSL

To secure the connection you need to add the following config key set to application.properties


How to generate keystore.jks?

Goto command prompt/terminal and execute the following keygen command

1keytool -genkey -keyalg RSA -alias quarkusdemo -keystore keystore.jks -storepass mypassword -validity 365 -keysize 2048

It will generate a keystore.jks file with password - “mypassword”.

Now you need to place this file inside - resources/keystore/keystore.jks

Test REST Endpoint using HTTPS

For testing, the REST Endpoint start your Quarkus Application


1./mvnw compile quarkus:dev

Gradle -

1./gradlew assemble quarkusDev

Test your endpoint in another command prompt/terminal

1>curl -I  https://localhost:8443/hello
2HTTP/1.1 200 OK
3Content-Type: application/json