Rocky Linux 10 Tutorial / Issue, renew and monitor HTTPS certificates
To operate HTTPS on Rocky Linux 10, you need to not only issue certificates but also apply them to the web server, execute automatic renewal, and monitor the actual served certificates and expiration. This tutorial reproduces actual ACME issuance and renewal using a separate test certificate authority and distinguishes DNS, ports, and trust conditions needed when applying to public services.
Difference between public certificates and local test certificates
HTTPS protects HTTP communication using TLS (Transport Layer Security). Certificate Authorities (CAs) sign certificates linking the site name and public key, and clients verify the name, validity period, and issuing chain. ACME (Automated Certificate Management Environment) is a protocol that automates domain control validation and issuance and renewal, and Certbot is a client that performs these actions.
As explained in Let’s Encrypt challenge documentation, public HTTP-01 validation requests the authentication file on port 80. The A·AAAA records used by the domain, external firewalls and port forwarding, and the actual web server path must all be correct. Simply changing your own hosts file or changing Certbot’s listening port to another number does not change the connection conditions of the public certification authority. DNS-01 validates through DNS TXT records and requires the DNS provider's automation method for automatic renewal.
| Environment | Validation scope and trust |
|---|---|
| This Pebble practice | Inside the VM, we actually verify the test name and HTTP-01. It is a private test CA and is not generally trusted by browsers. |
| Let’s Encrypt staging | Issued for testing with public DNS and access conditions. Test certificates are not generally trusted certificates. |
| Production Certification Authority | Issued to meet actual public domain and policy requirements. Client trust, names, chains, and external access are separately verified. |
Let’s Encrypt Staging Guide recommends testing before production issuance and introduces Pebble as a local ACME server for development. This exercise does not reflect results verified using staging or production issuance with a public domain.
Preparing Tools and Local ACME Test Environment
Proceed on a separate Rocky Linux 10 virtual machine. The source lab environment was Rocky Linux 10.2, Python 3.12.15, Certbot 5.10.0, Pebble 2.10.3, Nginx 1.26.3, OpenSSL 3.5.8, SELinux Enforcing. The Pebble distribution file below is for x86_64. For other CPU architectures, select the corresponding official distribution and checksum. Do not run as-is on servers that have existing sites, certificates, or practice files with the same names.
The EPEL Certbot package in this environment did not install because some dependencies do not match the Rocky 10.2 repository. Without forcibly replacing system packages, Certbot was installed in a dedicated Python virtual environment. In the Certbot installation documentation you can see that the pip method is a limited support method that uses a virtual environment. In production, installation methods and update responsibilities are determined together, and different Certbot installations are not mixed.
sudo dnf install python3 tar openssl nginx policycoreutils-python-utils
sudo ss -lntp
sudo bash <<'ROOT'
set -euo pipefail
test ! -e /root/lf-course26
test ! -e /usr/local/bin/lf-course26-pebble
for path in /etc/pki/tls/lf-course26 /etc/nginx/conf.d/lf-course26.conf /usr/local/sbin/lf-course26-deploy /usr/local/sbin/lf-course26-renew /etc/systemd/system/lf-course26-renew.service /etc/systemd/system/lf-course26-renew.timer; do
test ! -e "$path"
done
for port in 14000 15000 5001 5002 18426; do
listeners=$(ss -H -lnt "sport = :$port")
test -z "$listeners"
done
if grep -Eq '(^|[[:space:]])course26[.]test([[:space:]]|$)' /etc/hosts; then
printf 'The test hostname already exists in hosts. Stop.\n' >&2
exit 1
fi
install -d -m 0700 /root/lf-course26
cp -a /etc/hosts /root/lf-course26/hosts.before
cp -a /etc/nginx /root/lf-course26/nginx.before
python3 -m venv /root/lf-course26/venv
/root/lf-course26/venv/bin/python -m pip install 'certbot==5.10.0'
cd /root/lf-course26
curl -fL -o pebble.tar.gz https://github.com/letsencrypt/pebble/releases/download/v2.10.3/pebble-linux-amd64.tar.gz
printf '7e33cf3e426b67e9e647c44e8cc91683caa8ab331f7a99e5e27fcee291c4c7e2 pebble.tar.gz\n' | sha256sum -c -
tar -xzf pebble.tar.gz --strip-components=3
install -m 0755 pebble /usr/local/bin/lf-course26-pebble
restorecon /usr/local/bin/lf-course26-pebble
openssl req -x509 -newkey rsa:2048 -noenc -keyout api.key -out api.pem -days 2 -subj /CN=localhost -addext 'subjectAltName=DNS:localhost,IP:127.0.0.1'
chmod 0600 api.key
printf '\n127.0.0.1 course26.test # lf-course26\n' >> /etc/hosts
ROOT
Before execution, make sure that numbers 14000, 15000, 5002, and 18426 are not in use, and that course26.test is not in the existing hosts entries. The sudo bash inside runs with administrator privileges, and if an error occurs, subsequent commands are stopped. The expected SHA-256 value of the distribution archive should be compared with the release information of the official release. Do not execute if the hash is different.
Save the following content as sudoedit /root/lf-course26/pebble.json. The API access certificate api.pem and the certificates issued for subsequent sites are different from each other. Both APIs only receive connections on the loopback address and do not modify the system-wide CA store.
{
"pebble": {
"listenAddress": "127.0.0.1:14000",
"managementListenAddress": "127.0.0.1:15000",
"certificate": "/root/lf-course26/api.pem",
"privateKey": "/root/lf-course26/api.key",
"httpPort": 5002,
"tlsPort": 5001,
"keyAlgorithm": "ecdsa",
"profiles": {
"default": {
"description": "Local course26 test",
"validityPeriod": 7776000
}
}
}
}
sudo systemd-run --unit=lf-course26-pebble --property=WorkingDirectory=/root/lf-course26 --setenv=PEBBLE_VA_NOSLEEP=1 --setenv=PEBBLE_AUTHZREUSE=0 /usr/local/bin/lf-course26-pebble -config /root/lf-course26/pebble.json
sudo curl --retry 3 --retry-connrefused --cacert /root/lf-course26/api.pem -fsS https://localhost:14000/dir
sudo curl --cacert /root/lf-course26/api.pem -fsS https://localhost:15000/roots/0 -o /root/lf-course26/issuer-root.pem
The first query returns a JSON containing the ACME path, and the second saves the root certificate of the test issuance chain. PEBBLE_VA_NOSLEEP=1 only removes artificial delays, and PEBBLE_AUTHZREUSE=0 disables reuse of previous authorization results to observe repeated verification. Do not use modes that always treat verification as successful. The state of Pebble's certificate authority is stored in memory during execution, so do not assume that previous root, account, or issuance states are retained after a restart. If restarted, check the issuance and trust relationships of the new test environment again. For detailed settings, refer to Pebble 2.10.3 official README .
The first attempt to place the binary to be run by systemd in /root failed due to permission denial at the execution stage. After placing it in the standard execution path /usr/local/bin and restoring the context, it ran normally. When 203/EXEC appears, check journalctl -u lf-course26-pebble along with the file path, permissions, and SELinux context, and do not resolve it by disabling security features.
Issuing a test certificate via HTTP-01 validation
sudo env REQUESTS_CA_BUNDLE=/root/lf-course26/api.pem /root/lf-course26/venv/bin/certbot certonly --standalone --http-01-address 127.0.0.1 --http-01-port 5002 --preferred-challenges http --server https://localhost:14000/dir --config-dir /root/lf-course26/config --work-dir /root/lf-course26/work --logs-dir /root/lf-course26/logs --cert-name course26 --register-unsafely-without-email --agree-tos --non-interactive -d course26.test
sudo openssl x509 -in /root/lf-course26/config/live/course26/cert.pem -noout -serial -dates -issuer -ext subjectAltName
sudo journalctl -u lf-course26-pebble -n 25 --no-pager
This command creates an account only on the local test server, and a temporary standalone server provides the authentication file on port 5002. The option to omit the email is limited to this private test. REQUESTS_CA_BUNDLE is used only for the API TLS trust of that execution. There is no need for an option to skip TLS verification.
In the source logs, records show three verifications using http://course26.test:5002/.well-known/acme-challenge/... and the authentication was completed, and the certificate was issued. This port 5002 is the test port set in Pebble. This custom local port does not imply that a public HTTP-01 CA will validate on an arbitrary port.
cert.pem is the site certificate, chain.pem is the intermediate certificate, fullchain.pem is the site certificate and intermediate chain, and privkey.pem is the private key. The files inside live are symbolic links to versioned files in archive. Private keys and account keys should not be placed in the web document path or public backups. This setup sets the test validity period to 90 days, but do not assume a uniform validity period for production certificates; check the actual notAfter.
Applying to Nginx and verifying name and chain
The test site is provided only from 127.0.0.1:18426. Certificates are deployed to a dedicated TLS path that Nginx will read from, without exposing the Certbot storage path directly. First, check that the new path and port are not used in the existing configuration.
sudo install -d -m 0700 /etc/pki/tls/lf-course26
sudo install -m 0644 /root/lf-course26/config/live/course26/fullchain.pem /etc/pki/tls/lf-course26/fullchain.pem
sudo install -m 0600 /root/lf-course26/config/live/course26/privkey.pem /etc/pki/tls/lf-course26/privkey.pem
sudo restorecon -Rv /etc/pki/tls/lf-course26
sudo semanage port -a -t http_port_t -p tcp 18426
Save the entire server block to sudoedit /etc/nginx/conf.d/lf-course26.conf. Maintain the default site configuration on port 80.
server {
listen 127.0.0.1:18426 ssl;
server_name course26.test;
ssl_certificate /etc/pki/tls/lf-course26/fullchain.pem;
ssl_certificate_key /etc/pki/tls/lf-course26/privkey.pem;
location / {
default_type text/plain;
return 200 "LF26 HTTPS works\n";
}
}
sudo nginx -t && sudo systemctl start nginx
sudo curl --cacert /root/lf-course26/issuer-root.pem --resolve course26.test:18426:127.0.0.1 -sS -w 'HTTP %{http_code}\n' https://course26.test:18426/
If Nginx is already running, apply the new settings with sudo systemctl reload nginx instead of start. This exercise was checked in the case started from a stopped state. LF26 HTTPS works and 200 are the expected results. --resolve specifies only the access address for this request while maintaining the URL name and TLS SNI (Server Name Indication). --cacert specifies only the test CA for this lab and does not change the trust settings of a regular browser.
In actual comparison, curl without specifying the test root failed with exit code 60 because it could not trust the issuance chain. Even if the test root is specified, changing the URL name to wrong26.test results in the same exit code 60 due to certificate name mismatch. Do not distinguish the cause by exit code alone; check the error message as well. Verify both successful TLS negotiation and the server identity presented to the client. This test does not configure mutual TLS client authentication.
Actual renewal and deployment hook verification
Even if Certbot saves a new certificate file, the Nginx certificate copied to a separate path does not change automatically. The deploy hook, executed after successful renewal, handles copying, context restoration, configuration check, and reload. Save the following content as sudoedit /usr/local/sbin/lf-course26-deploy. This hook is limited to the test name and storage path for this lab.
#!/bin/bash
set -euo pipefail
test "${RENEWED_LINEAGE:-}" = /root/lf-course26/config/live/course26
openssl x509 -in "$RENEWED_LINEAGE/cert.pem" -noout -checkend 0
openssl verify -CAfile /root/lf-course26/issuer-root.pem -untrusted "$RENEWED_LINEAGE/chain.pem" -verify_hostname course26.test "$RENEWED_LINEAGE/cert.pem"
BACKUP=$(mktemp -d /root/lf-course26/deploy-backup.XXXXXXXX)
cp -a /etc/pki/tls/lf-course26/fullchain.pem /etc/pki/tls/lf-course26/privkey.pem "$BACKUP/"
install -m 0644 "$RENEWED_LINEAGE/fullchain.pem" /etc/pki/tls/lf-course26/fullchain.pem
install -m 0600 "$RENEWED_LINEAGE/privkey.pem" /etc/pki/tls/lf-course26/privkey.pem
restorecon -R /etc/pki/tls/lf-course26
if ! nginx -t || ! systemctl reload nginx; then
install -m 0644 "$BACKUP/fullchain.pem" /etc/pki/tls/lf-course26/fullchain.pem
install -m 0600 "$BACKUP/privkey.pem" /etc/pki/tls/lf-course26/privkey.pem
nginx -t && systemctl reload nginx
exit 1
fi
openssl x509 -in "$RENEWED_LINEAGE/cert.pem" -noout -serial >> /root/lf-course26/deploy-serials.log
Before applying, check the chain, name, and expiration date, and store the existing deployment files in a protected location. If the configuration check or reload fails, revert the previous deployment files and exit with an error. If restoration also fails, you must check the service logs and the actual response, and it will not be considered a successful automatic recovery. This time, the path where the normal certificate was deployed was executed for verification, and this failure recovery branch was not deliberately reproduced.
Save the following content as sudoedit /usr/local/sbin/lf-course26-renew. Execute the Certbot console script with Python in the virtual environment.
#!/bin/bash
set -euo pipefail
export REQUESTS_CA_BUNDLE=/root/lf-course26/api.pem
exec /root/lf-course26/venv/bin/python /root/lf-course26/venv/bin/certbot renew --server https://localhost:14000/dir --config-dir /root/lf-course26/config --work-dir /root/lf-course26/work --logs-dir /root/lf-course26/logs --cert-name course26 --non-interactive --no-random-sleep-on-renew --deploy-hook /usr/local/sbin/lf-course26-deploy "$@"
sudo chmod 0750 /usr/local/sbin/lf-course26-deploy /usr/local/sbin/lf-course26-renew
sudo restorecon /usr/local/sbin/lf-course26-deploy /usr/local/sbin/lf-course26-renew
sudo /usr/local/sbin/lf-course26-renew --force-renewal
sudo openssl x509 -in /root/lf-course26/config/live/course26/cert.pem -noout -serial
sudo bash -o pipefail <<'BASH'
openssl s_client -connect 127.0.0.1:18426 -servername course26.test -verify_hostname course26.test -CAfile /root/lf-course26/issuer-root.pem -verify_return_error </dev/null | openssl x509 -noout -serial
BASH
--force-renewal is an option to observe the renewal in this local test. Forced renewal is not applied to the production timer. The initial serial number was 4DFCA979CEB14834, and the number saved and provided after actual renewal was 4E9CBB509103CA00. In the first connection immediately after the reload command, the previous certificate was briefly observed, and after reconnecting, the match between the saved number and the provided number was confirmed. Do not judge that the service application is completed just by checking the command’s completion.
sudo bash <<'ROOT'
set -euo pipefail
sha256sum /root/lf-course26/config/live/course26/cert.pem > /root/lf-course26/dryrun-before.sha256
/usr/local/sbin/lf-course26-renew --dry-run --run-deploy-hooks
sha256sum -c /root/lf-course26/dryrun-before.sha256
ROOT
The actual simulated renewal successfully executed HTTP-01 and hooks, and the current certificate hash remained the same. The hooks specified for the dry-run in --run-deploy-hooks use the currently active certificate, not a temporary test certificate. Operation and options can also be confirmed in Certbot User Guide . A successful dry-run does not mean the current file has been replaced with a new certificate.
Verify separately the timer execution and expiration monitoring.
Save the following services in sudoedit /etc/systemd/system/lf-course26-renew.service.
[Unit]
Description=Local course26 certificate renewal test
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/lf-course26-renew
Save the following timers in sudoedit /etc/systemd/system/lf-course26-renew.timer. OnActiveSec=3s is a line for observing immediate scheduled execution in practice. In an actual operating cycle, except for this test line, set execution times and distribution delays according to the service load and management policy.
[Unit]
Description=Local course26 renewal timer test
[Timer]
OnActiveSec=3s
OnCalendar=*-*-* 03,15:00:00
Persistent=true
Unit=lf-course26-renew.service
[Install]
WantedBy=timers.target
sudo systemctl daemon-reload
sudo systemctl start lf-course26-renew.timer
systemctl list-timers lf-course26-renew.timer --no-pager
systemctl show lf-course26-renew.service -p Result -p ExecMainStatus -p ActiveState
sudo journalctl -u lf-course26-renew.service -n 25 --no-pager
The source timer call occurred after 3 seconds, and the final states were Result=success, ExecMainStatus=0, and ActiveState=inactive. The certificate was not yet due for renewal, so the log recorded that reissuance and deploy hooks were skipped. Therefore, 'the timer ran,' 'attempted to refresh,' and 'issued/distributed a new certificate' are separate confirmation items. It is normal for a oneshot service to be inactive after finishing normally. 'Start' refers to this boot execution, and enable settings are required separately for automatic execution on reboot.
sudo openssl x509 -in /root/lf-course26/config/live/course26/cert.pem -noout -enddate
sudo openssl x509 -in /root/lf-course26/config/live/course26/cert.pem -noout -checkend 604800
sudo openssl x509 -in /root/lf-course26/config/live/course26/cert.pem -noout -checkend 8640000
This test certificate does not expire within 7 days, resulting in exit code 0 in a 604,800-second check, and it expires within 100 days, resulting in 1 in an 8,640,000-second check. The latter does not mean "already expired." -checkend checks expiration within the specified number of seconds. Please check the meaning of options in the OpenSSL x509 document . Operational monitoring checks not only local files but also certificates actually provided externally, and in case of failure, the notification route should be tested so that the administrator can be informed.
Conditions to change when applying to public services
On an actual domain, private test CAs, hosts entries, port 5002 verification, and loopback APIs are not used. First, check public DNS and external port 80 connections, and if you want to maintain the existing web server, you can provide the authentication file using the webroot method. Prepare a separate Certbot path and configuration directory for operation, and do not mix test accounts or test certificates with operational certificates.
- Verify that the A and AAAA records of your domain point to the actual server and are accessible externally. Also, check that unused IPv6 records do not point to incorrect servers.
- In Nginx, verify from the outside that the
/.well-known/acme-challenge/test file is being served at the correct document path. Hidden path blocking, authentication requirements, or incorrect redirects can interfere with verification. - First, perform public staging verification from the operational Certbot to
certonly --webroot -w /srv/example-webroot -d www.example.com --dry-run. Replace the example webroot and domain with your real values, enter a reachable account email and review the CA terms. - After a successful test, perform the operational issuance and apply the full chain and private key paths to Nginx. The operational renewal hooks must be written according to the actual path, name, and trust chain, and the private CA hooks from this tutorial should not be reused as-is.
- Check the external response on port 443, name, chain, expiration, renewal dry-run and deployment hook, and the next execution and recent result of the timer. Also, follow the issuance and renewal policies and restrictions required by the public CA.
This section is for the conditions for switching to public service. Local verification this time cannot be considered as confirmation of DNS, internet firewall, or issuance by a public certificate authority for the domain you actually own.
Stopping the test environment and restoring existing settings
After finishing the test, first stop the timer and Pebble. Move the Nginx files you created to the backup location, and after inspection and reload, only the existing default site remains.
sudo systemctl stop lf-course26-renew.timer lf-course26-renew.service lf-course26-pebble.service
sudo mv /etc/nginx/conf.d/lf-course26.conf /root/lf-course26/lf-course26.conf.saved
sudo nginx -t && sudo systemctl reload nginx
sudo semanage port -d -p tcp 18426
sudo rm -- /etc/systemd/system/lf-course26-renew.service /etc/systemd/system/lf-course26-renew.timer
sudo systemctl daemon-reload
In hosts, remove only the exact line added this time. If there are no other edits, it can be restored by comparing with the protected original. Also, after checking ownership, remove unused test executables, dedicated distribution certificates, and timer state files, and keep files or rules used by other sites. If you store secret keys and account information, protect them with root-only permissions as before.
After cleanup in the source lab, Nginx, firewall settings, hosts, and SELinux local policy were the same as before the exercise, and the content of the existing default site was also the same. SSH and firewalld remained active, and SELinux stayed in Enforcing mode. Test API, HTTPS listeners, and scheduled tasks were removed, and only the dedicated log folder was kept with 0700 permissions.




