Rocky-9.2 and Let's Encrypt certificate

Distribution: Rocky-9.2
NethServer Version: 8 beta
Module: mail & webtop, etc…

Hi all,

I got a Let’s Encrypt test certificate with acme.sh.

[root@hote ~]# ls -als /root/.acme.sh/rocky.toto.org_ecc
total 36
4 drwxr-xr-x. 2 root root 4096 Jun 25 22:00 .
0 drwx------. 7 root root  186 Jun 25 21:58 ..
4 -rw-r--r--. 1 root root 2772 Jun 25 22:00 ca.cer
8 -rw-r--r--. 1 root root 4330 Jun 25 22:00 fullchain.cer
4 -rw-r--r--. 1 root root 1558 Jun 25 22:00 rocky.toto.org.cer
4 -rw-r--r--. 1 root root  783 Jun 25 22:00 rocky.toto.org.conf
4 -rw-r--r--. 1 root root  700 Jun 25 21:58 rocky.toto.org.csr
4 -rw-r--r--. 1 root root  358 Jun 25 21:58 rocky.toto.org.csr.conf
4 -rw-------. 1 root root  227 Jun 25 21:58 rocky.toto.org.key
[root@hote ~]#

Which files and where do I have to copy them ?

Any help appreciated,

Michel-André

Hi! Thank you for testing NethServer 8 Beta!
We’ve just recently added the entry in the manual at this link.
Just be sure to run the up to date versions:

  • core version should be 1.1.0 or greater
  • traefik module should be 0.0.13 or greater

(if you have trouble finding the core/modules versions you can find them in Software center → kebab menu on the top right, near Reload repositoriesCore apps)

2 Likes

Hi @Tbaile

Thank you for your reply.

[root@hote ~]#  podman images
REPOSITORY                    TAG                    IMAGE ID      CREATED        SIZE
ghcr.io/nethserver/core       ns8-stable             c58951300107  3 days ago     120 MB
ghcr.io/nethserver/redis      1.1.0                  456288737fa4  3 days ago     31.4 MB
ghcr.io/nethserver/traefik    0.0.13                 fe1dc0419348  4 days ago     134 kB
ghcr.io/nethserver/webtop     1.0.2                  77a9eaef9391  7 days ago     8.53 MB
ghcr.io/nethserver/mail       1.2.0-git.10.gb73cd7c  9edc357b3dce  9 days ago     9.88 MB
ghcr.io/nethserver/openldap   1.0.0                  9ec3d2d868c7  7 weeks ago    78.1 kB
ghcr.io/nethserver/loki       0.0.3                  6704b79e5bba  3 months ago   22.7 kB
ghcr.io/nethserver/promtail   0.0.3                  af18942b5abe  3 months ago   24.2 kB
ghcr.io/nethserver/ldapproxy  0.0.6                  dc2f9f82e533  3 months ago   25.8 kB
docker.io/grafana/promtail    2.7.3                  76c7ed0ad4db  4 months ago   193 MB
docker.io/rclone/rclone       1.57.0                 15965416f78a  20 months ago  51 MB
[root@hote ~]#

I asked a production certificate, not a test one.

I tried to upload: rocky.toto.org.key and fullchain.cer

The key failed and it didn’t even test the chain…

Any suggestion ?

Michel-André

EDIT:
With NethServer-7.9:

                       --cert-file /etc/pki/tls/certs/cert.crt                      \
                       --ca-file /etc/pki/tls/certs/cert-chain.crt                  \
                       --key-file /etc/pki/tls/private/cert.key                     \

Maybe I have to rename fullchain.cer / rocky.toto.org.key or convert to another format ???

EDIT:
With NethServer-7.9:
They all are .pem

image

Hi @Tbaile

Finally I succeeded.

Yesterday, I asked a Let’s Encrypt cert on my main server after entering the DNS (hosts), created a MAIL to LOCAL, and Revere Proxy all (with the CNAME created by it) to point to LOCAL IP.

On my main server, in the archive directory of Let’s Enscrypt under rocky.toto.org
image

I copy the directory on my station and I uploaded privkey1.pem and fullchain.pem to the Rocky server.

All went OK.

I didn’t take any chances and reboot the Virtual Machine.

After reboot, I just refreshed the page in the browser.

The padlock on the left of the URL was closed.
image

I checked the certificate:

All looks good…

I would still like to do it on the Virtual Machine with acme.sh… but this is another story…

Michel-André

You say you uploaded these files, but the screen shot you posted indicates you uploaded account.key. If that’s the case, it would explain the error; that’s your ACME account private key, which would not correspond to any certificate you’d obtained.

Hi @danb35

Thank you for your reply.

You mean that I should have uploaded cert1.pem instead of privkey1.pem ?

Michel-André

No, that would not have worked. I’m referring to your earlier attempt, where you’d obtained the cert using acme.sh. The screen shot you uploaded shows that you uploaded your ACME account private key (account.key), not the private key for the cert (rocky.toto.org.key). You should never be uploading the account private key, and it’d really be pretty unusual for you to deal with it at all.

Hi @danb35

I deleted Webtop and installed Rouncubemail and asked a new cert including it.

I will try again and let you know.

Michel-André

Hi @danb35

I tried all other and it didn’t work.
I gives error on upload.

Michel-André

Luckily the issue reported by the UI is tightly coupled to the actual OpenSSL command run by the api-server, would you kindly run openssl rsa -check -in $KEY_FILE, replacing $KEY_FILE with the key generated by acme.sh? Thank you

Hi @Tbaile

Thank you for your reply.

Directory/files created by acme.sh

[root@hote rocky.toto.org_ecc]# ls -als
total 36
4 drwxr-xr-x. 2 root root 4096 Jun 25 22:11 .
0 drwx------. 7 root root  186 Jun 26 09:24 ..
4 -rw-r--r--. 1 root root 3751 Jun 26 09:57 ca.cer
8 -rw-r--r--. 1 root root 5552 Jun 26 09:57 fullchain.cer
4 -rw-r--r--. 1 root root 1801 Jun 26 09:57 rocky.toto.org.cer
4 -rw-r--r--. 1 root root  815 Jun 26 09:57 rocky.toto.org.conf
4 -rw-r--r--. 1 root root  790 Jun 26 09:55 rocky.toto.org.csr
4 -rw-r--r--. 1 root root  424 Jun 26 09:55 rocky.toto.org.csr.conf
4 -rw-------. 1 root root  227 Jun 25 22:09 rocky.toto.org.key <===============
[root@hote rocky.toto.org_ecc]#

[root@hote rocky.toto.org_ecc]# openssl rsa -check -in rocky.toto.org.key
Not an RSA key  <===============================================================
[root@hote rocky.toto.org_ecc]#

Directory/files created by myself with content copied from main server PASSERELLE Let’s Encrypt created archive directory for rocky.toto.org

[root@hote Cert_PASSERELLE]# ls -als
total 20
0 drwxr-xr-x. 2 root root   83 Jun 27 08:39 .
4 dr-xr-x---. 8 root root 4096 Jun 27 08:39 ..
4 -rw-r--r--. 1 root root 2090 Jun 26 15:43 cert2.pem
4 -rw-r--r--. 1 root root 1826 Jun 26 15:43 chain2.pem
4 -rw-r--r--. 1 root root 3916 Jun 26 15:43 fullchain2.pem
4 -rw-r--r--. 1 root root 1704 Jun 26 15:43 privkey2.pem  <=====================
[root@hote Cert_PASSERELLE]#

[root@hote Cert_PASSERELLE]#  openssl rsa -check -in privkey2.pem
RSA key ok   <======================================================
writing RSA key
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCnA3tmnDDbkmqh
6U7EWnJqs9TVq4Z/ApBOGkx/AcztlAQ/Eyt/qRWOMsHtWbidLIZO7aCq0Jr8dc9U
JfRKj+9S/G2i9mB+5fY/HI853PM3zTaBIh4sVurEfd6GwMVk7CKpLKUjA+yUe4VR
...
zx1RekrHL5q/AnNnXtL04fo4qr1JDVqn8MKryGZ53A3CqwZUKhzpzj93snNIvuQz
wU29kG3hxZ5GQO/6nuuJ8eyU/AJTI1hsvBX613x24Y0H/CtsQu7kvszKwaGzqUZv
ImMbjtmohazzw9XSPUdjThZr
-----END PRIVATE KEY-----
[root@hote Cert_PASSERELLE]#

Conclusion:
rocky.toto.org.key created by acme.sh is Not an RSA key
privkey2.pem created by Let’s Encrypt => RSA key ok

In NethSerer-7.9, the last parameter of acme.sh => "/sbin/e-smith/signal-event certificate-update" transforms the key files in the right format before copying them to their proper places ?

Tommaso,

  1. What is your conclusions about the results of that test ?
  2. Should I continue to use the files created by Let’s Encrypt and copied to NS8 ?
  3. Try to modify the comand "/sbin/e-smith/signal-event certificate-update" to do the job (this should be a little complex) ?
    Fo sure, one day the NS8 dev team will have to come up with a startegy for acme.sh for LOCAL NS8 as they did for NethServer-7.x.

Michel-André

Okay then! We found the “culprit”!

Tests are needed using certificates from acme.sh, at least to figure out what’s wrong about the key (haven’t touched the tool yet and I’ve found out about it with this post :smiley:)

Is there a specific need for this? NS8 automatically does that for you through the Request Certificate function, please clarify if the feature lacks something, feedback is always welcome!

Not sure about this due to the limited knowledge I’ve got on NS7, maybe someone with more know-how will help me figure something out.

Traefik handles for himself basically every certificate you can give to it, probably this is something just related to the output of acme.sh. BTW here’s the script that validates the key/certificates, maybe you can check the acme.sh output against this commands so we can figure out what’s wrong.

Thank you for your patience!

Hi @Tbaile

Thank you for your search and reply.

In the script mentioned, the line:

if ! openssl rsa -check -in $KEY_FILE >/dev/null 2>&1; then

is the same as the test you gave above.

Also, the first block of code deletes the uploaded certificate files:

del_certs() {
    rm -f $KEY_FILE $CERT_FILE
}

Since I am on a LOCAL virtual machine, i doubt the system can ask a certificate as the
challenges will not get a good response.
I remember, at some point, I allow the certificate demand and it failled.

Hoping the dev team will add some parameters to the acme.sh script to transform the certificates
into the proper format and upload them like the way they upload certs in the UI manager.

Michel-André