Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quarkus HTTPS restful service

Tags:

quarkus

Is there any example/tutorial to build and configure TLS-secured restful service using quarkus.io?

Unfortunately I can not find one neither at quarkus documentation, no here.

like image 903
S. Kadakov Avatar asked Apr 09 '19 08:04

S. Kadakov


1 Answers

Thanks mr. Guillaume Smet, I found the solution. Here is "from zero to hello in 5 minutes with Quarkus and SSL guide". This is done by quarkus undertow plugin. Also you will need text editor, jdk 1.8+ and maven installed.

Frist, create the project.

mkdir restls
cd restls
mvn io.quarkus:quarkus-maven-plugin:create -DprojectGroupId=org.acme -DprojectArtifactId=restls -DclassName="org.acme.HelloResource" -Dpath="/hello" -Dextensions="undertow"

Open your application config file src/main/resources/application.properties with any editor and add lines:

quarkus.http.port=80
quarkus.http.ssl-port=443
quarkus.http.ssl.certificate.key-store-file=keystore.jks

Create keystore containing self-signed certificate (answer all questions and specify password namelly "password"):

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

The file keystore.jks must be in the src/main/resources/ folder.

Build the project:

mvnw clean package quarkus:build

Now try it out:

java -jar target/restls-1.0-SNAPSHOT-runner.jar

Navigate to https://localhost/hello and allow your browser to trust certificate. That's all.

You can override options in invocation time like this:

java -Dquarkus.http.ssl.certificate.key-store-file=/path-to-keystore/keystore-name.jks -jar target/restls-1.0-SNAPSHOT-runner.jar

Finally, here is the concerning options list:

quarkus.http.ssl.certificate.file -- The file path to a server certificate or certificate chain in PEM format.

quarkus.http.ssl.certificate.key-file -- The file path to the corresponding certificate private key file in PEM format.

quarkus.http.ssl.certificate.key-store-file -- An optional key store which holds the certificate information instead of specifying separate files.

quarkus.http.ssl.certificate.key-store-file-type -- An optional parameter to specify type of the key store file. If not given, the type is automatically detected based on the file name.

You can specifiy either certificate + key files in PEM format or keystore.

like image 152
S. Kadakov Avatar answered Nov 24 '22 01:11

S. Kadakov