You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _versions/main/guides/tls-registry-reference.adoc
+190Lines changed: 190 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -693,3 +693,193 @@ To handle the renewal, you can use the periodic reloading mechanism:
693
693
%prod.quarkus.http.insecure-requests=disabled
694
694
----
695
695
696
+
== Quarkus CLI commands and development CA (Certificate Authority)
697
+
698
+
The TLS registry provides CLI commands to generate a development CA and trusted certificates.
699
+
This avoids having to use self-signed certificates locally.
700
+
701
+
[source, shell]
702
+
----
703
+
> quarkus tls
704
+
Install and Manage TLS development certificates
705
+
Usage: tls [COMMAND]
706
+
Commands:
707
+
generate-quarkus-ca Generate Quarkus Dev CA certificate and private key.
708
+
generate-certificate Generate a TLS certificate with the Quarkus Dev CA if
709
+
available.
710
+
----
711
+
712
+
In most cases, you generate the Quarkus Development CA once, and then generate certificates signed by this CA.
713
+
The Quarkus Development CA is a Certificate Authority that can be used to sign certificates locally.
714
+
It is only valid for development purposes and only trusted on the local machine.
715
+
The generated CA is located in `$HOME/.quarkus/quarkus-dev-root-ca.pem`, and installed in the system trust store.
716
+
717
+
=== CA, signed vs. self-signed certificates
718
+
719
+
When developing with TLS, you can use two types of certificates:
720
+
721
+
- a self-signed certificate: the certificate is signed by the same entity that uses it. It is not trusted by default. It's generally what we use when we don't have a CA, or don't want to dig too much into TLS. This is not a production setup, and may be used only for development.
722
+
- a signed certificate: the certificate is signed by a Certificate Authority (CA). The CA is a trusted entity that signs the certificate. The certificate is trusted by default. This is what we use in production.
723
+
724
+
We could use self-signed certificate when running application locally, but it's not always convenient.
725
+
Typically, browsers will not trust the certificate, and you will have to import it manually.
726
+
`curl`, `wget`, `httpie` and other tools will also not trust the certificate.
727
+
728
+
To avoid this, we can use a development CA to sign the certificates, and install it into the system trust store.
729
+
Thus, every certificate signed by this CA will be trusted by the system.
730
+
731
+
Quarkus makes it easy to generate a development CA and certificates signed by this CA.
732
+
733
+
=== Generate a development CA
734
+
735
+
The development CA is a Certificate Authority that can be used to sign certificates locally.
736
+
Note that the generated CA is only valid for development purposes, and only trusted on the local machine.
737
+
738
+
To generate a development CA, use the following command:
`--install` installs the CA in the system trust store.
746
+
Windows, Mac and Linux (Fedora and Ubuntu) are supported.
747
+
However, depending on your browser, you may need to import the generated CA manually.
748
+
Refer to the browser documentation for more information.
749
+
The generated CA is located in `$HOME/.quarkus/quarkus-dev-root-ca.pem`.
750
+
751
+
WARNING: When installing the certificate, your system may ask for your password to install the certificate in the system trust store, or ask for confirmation in a dialog (on Windows).
752
+
753
+
IMPORTANT: On Windows, makes sure you run from an elevated terminal (run as administrator) to install the CA in the system trust store.
754
+
755
+
`--renew` renews the CA if it already exists.
756
+
When this option is used, you need to re-generate the certificates that were signed by the CA, as the private key is changed.
757
+
Note that if the CA expires, it will automatically be renewed (without passing `--renew`).
758
+
759
+
`--truststore` also generates a PKCS12 trust store containing the CA certificate.
760
+
761
+
=== Generate a trusted (signed) certificate
762
+
763
+
Once you have installed the Quarkus Development CA, you can generate a trusted certificate.
764
+
It will be signed by the Quarkus Development CA, and so trusted by your system.
765
+
766
+
[source, shell]
767
+
----
768
+
quarkus tls generate-certificate --name my-cert
769
+
----
770
+
771
+
This generates a certificate signed by the Quarkus Development CA, and so if properly installed / imported, will be trusted by your system.
772
+
773
+
The certificate is stored in `./.certs/`.
774
+
Two files are generated:
775
+
776
+
- `$NAME-keystore.p12` - contains the private key and the certificate. It's password protected.
777
+
- `$NAME-truststore.p12` - contains the CA certificate, that you can used as trust store (for test, for instance).
Generate a TLS certificate with the Quarkus Dev CA if available.
786
+
-c, --cn=<cn> The common name of the certificate. Default is 'localhost'
787
+
-d, --directory=<directory>
788
+
The directory in which the certificates will be created.
789
+
Default is `.certs`
790
+
-n, --name=<name> Name of the certificate. It will be used as file name and
791
+
alias in the keystore
792
+
-p, --password=<password>
793
+
The password of the keystore. Default is 'password'
794
+
-r, --renew Whether existing certificates will need to be replaced
795
+
----
796
+
797
+
When generating the certificate, a `.env` file is also generated making the Quarkus dev mode aware of these certificates.
798
+
So, then, if you run your application in dev mode, it will use these certificates:
799
+
800
+
[source, shell]
801
+
----
802
+
./mvnw quarkus:dev
803
+
...
804
+
INFO [io.quarkus] (Quarkus Main Thread) demo 1.0.0-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 1.286s. Listening on: http://localhost:8080 and https://localhost:8443
805
+
----
806
+
807
+
Now, you can open the Dev UI using HTTPS: `https://localhost:8443/q/dev`, or issue a request using `curl`:
808
+
809
+
[source, shell]
810
+
----
811
+
curl https://localhost:8443/hello
812
+
Hello from Quarkus REST%
813
+
----
814
+
815
+
IMPORTANT: If the Quarkus Development CA is not installed, a self-signed certificate is generated.
816
+
817
+
818
+
=== Generating a self-signed certificate
819
+
820
+
Even if the Quarkus Development CA is installed, you can generate a self-signed certificate:
0 commit comments