Skip to content

Commit 272044d

Browse files
committed
📝 Add how Configure TLS with certificate generated with letsencrypt client Lego
1 parent 8afdf5e commit 272044d

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

docs/security/tls.adoc

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,81 @@ link:https://letsencrypt.org[Let's Encrypt] is a popular and nonprofit Certifica
8181
This script generates the java keystore from Let's Encrypt certificate archive.
8282

8383
Download the script from link:https://raw.githubusercontent.com/SoftInstigate/restheart/master/core/bin/convert-letsencrypt-java-keystore.sh[convert-letsencrypt-java-keystore.sh]
84+
85+
I'll improve the documentation section with better structure, clearer instructions, and more helpful guidance:
86+
87+
88+
==== Example: Generating SSL Certificates with Lego
89+
90+
https://go-acme.github.io/lego/[Lego] is a robust Let's Encrypt client and ACME library written in Go that simplifies the process of generating SSL certificates through various verification methods.
91+
92+
This example demonstrates using Lego with the DNS route53 provider, assuming AWS credentials are already configured in your environment. The process can be adapted to use any of the https://go-acme.github.io/lego/dns/index.html[supported DNS providers].
93+
94+
===== Step 1: Generate the Certificate
95+
96+
Replace `restheart.org` with your domain name throughout these examples.
97+
98+
[source,bash]
99+
----
100+
$ lego --email andrea@restheart.org --dns route53 -d restheart.org run
101+
2025/03/26 09:49:44 [INFO] [restheart.org] acme: Obtaining bundled SAN certificate
102+
2025/03/26 09:49:45 [INFO] [restheart.org] AuthURL: https://acme-v02.api.letsencrypt.org/acme/authz/2302497476/495306646876
103+
2025/03/26 09:49:45 [INFO] [restheart.org] acme: authorization already valid; skipping challenge
104+
2025/03/26 09:49:45 [INFO] [restheart.org] acme: Validations succeeded; requesting certificates
105+
2025/03/26 09:49:46 [INFO] [restheart.org] Server responded with a certificate
106+
107+
$ ls .lego/certificates
108+
restheart.org.crt restheart.org.issuer.crt restheart.org.json restheart.org.key
109+
----
110+
111+
After execution, Lego creates the certificate files in the `.lego/certificates` directory.
112+
113+
===== Step 2: Convert Certificates to Java Keystore
114+
115+
Use the provided script to convert the Let's Encrypt certificates into a Java keystore format:
116+
117+
[source,bash]
118+
----
119+
./convert-letsencrypt-java-keystore.sh \
120+
-d restheart.org \
121+
-c .lego/certificates/restheart.org.crt \
122+
-k .lego/certificates/restheart.org.key \
123+
-i .lego/certificates/restheart.org.issuer.crt \
124+
-p secret
125+
----
126+
127+
Output:
128+
[source]
129+
----
130+
Convert Let's Encrypt certificates to PKCS 12 archive
131+
Import certificates into a keystore file.
132+
Keystore import .lego/certificates/restheart.org.p12 in .lego/certificates/restheart.org.jks in corso...
133+
Add the necessary Let's Encrypt intermediate certs.
134+
% Total % Received % Xferd Average Speed Time Time Time Current
135+
Dload Upload Total Spent Left Speed
136+
100 1826 100 1826 0 0 13977 0 --:--:-- --:--:-- --:--:-- 14046
137+
The certificate has been added to the keystore
138+
----
139+
140+
This creates a Java keystore file at `.lego/certificates/restheart.org.jks` with the password `secret`.
141+
142+
===== Step 3: Configure RESTHeart with HTTPS
143+
144+
Run RESTHeart with the HTTPS listener enabled using the generated keystore:
145+
146+
[source,bash]
147+
----
148+
$ RHO='/https-listener->{
149+
"enabled": true,
150+
"host": "restheart.org",
151+
"port": 4443,
152+
"keystore-path": ".lego/certificates/restheart.org.jks",
153+
"keystore-password": "secret",
154+
"certificate-password": "secret"
155+
}' java -jar restheart.jar
156+
----
157+
158+
[TIP]
159+
====
160+
For production use, choose a strong password instead of "secret" and secure your keystore file with appropriate permissions.
161+
====

0 commit comments

Comments
 (0)