Control Web Panel

WebPanel => SSL => Topic started by: cfreire on May 08, 2025, 03:38:04 PM

Title: Probelm with renewing SSL certs
Post by: cfreire on May 08, 2025, 03:38:04 PM
Hi I have intended renew my expired certs, webmail... cpanel... etc. In the web interface the renewing is success aparently, but when I reload the webpage, the advice tahr "expired" is still there.  When I check in /etc/pki/tls/certs the .cert files, effectively, they are expired. Somethig is avoiding that the .cert or blundle files be rewriting.
How can I resolv this problem please?? Regards.
Title: Re: Probelm with renewing SSL certs
Post by: Netino on May 09, 2025, 01:38:16 AM
Possibly a bug from CWP.
This happened to me migrating domains from another server.
Once the domain was renewed manually, now the renewing process is automatic again.

Try to create a script, named like 'renew-cert.sh', to renew manually:
Code: [Select]
#!/bin/bash

DOM=${1}
/root/.acme.sh/acme.sh --home /root/.acme.sh/cwp_certs --renew --ecc -d ${DOM} --force

Change permissions:
Code: [Select]
# chmod 700 renew-cert.sh
And run the script (replacing "domain.com" with your domain):
Code: [Select]
# ./renew-cert.sh domain.com
Regards,
Netino
Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 12, 2025, 06:17:36 PM
I tried with the script, it was going well but finally I got the next error:

cxxxxxxxxxxx.cxx: Invalid status. Verification error details: 157.90.211.236: Fetching http://cxxnxxxx.com/.well-known/acme-challenge/rxt3tCYUqpgL_DtbRhDA7ik31_RQrp_bt1cvzc1jXyk: Timeout during connect (likely firewall problem)
[Mon May 12 13:12:40 -05 2025] Please check log file for more details: /root/.acme.sh/cwp_certs/acme.sh.log
[root@ ~]#

And effectively, I have migrated this domain from another server. our help please. Thanks.
Title: Re: Probelm with renewing SSL certs
Post by: overseer on May 13, 2025, 12:24:41 AM
Is your firewall allowing in & outbound port 80? Is iptables configured similarly to this:
Code: [Select]
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPTYou could temporarily disable the CSF firewall (csf -x) and test a renewal, either from the CWP web GUI or via Netino's script. This would tell you if it is a firewall problem, which it would appear to be.
Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 13, 2025, 02:36:58 PM
Ah but the website is in other server that I dont adimistrate. How can I to change the comprobation mode?
Title: Re: Probelm with renewing SSL certs
Post by: Netino on May 14, 2025, 02:20:06 AM
Ah but the website is in other server that I dont adimistrate. How can I to change the comprobation mode?

You simply can't get certificates via LetsEncrypt in apache mode if you can't save tokens in a specific are of the web server.
But with another app (certbot) in DNS mode, you could.
You manage the DNS server of these sites?

Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 14, 2025, 04:58:45 PM
Hi, of course, I manage the DNS ZOne of the domain.... Then, how can I procedure?
Title: Re: Probelm with renewing SSL certs
Post by: overseer on May 14, 2025, 06:42:56 PM
Use certbot (an ACME client) and run with a configuration like this (obtaining an API key from your DNS provider -- Cloudflare, in this example):
/etc/letsencrypt/renewal/yourdomain.com.conf
Code: [Select]
# renew_before_expiry = 30 days
version = 1.8.0
archive_dir = /etc/letsencrypt/archive/yourdomain.com
cert = /etc/letsencrypt/live/yourdomain.com/cert.pem
privkey = /etc/letsencrypt/live/yourdomain.com/privkey.pem
chain = /etc/letsencrypt/live/yourdomain.com/chain.pem
fullchain = /etc/letsencrypt/live/yourdomain.com/fullchain.pem

# Options used in the renewal process
[renewalparams]
account = YOURAPIKEYHERE
authenticator = dns-cloudflare
dns_cloudflare_propagation_seconds = 60
dns_cloudflare_credentials = /some/path/conf/yourdomain.com.key
server = https://acme-v02.api.letsencrypt.org/directory
Then you just call certbot renew in cron and it will renew your SSL cert 30 days before expiry.
Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 14, 2025, 08:59:52 PM
Hi, thanks by your reply..... What about if does not exist the folders letsencrypt/renewal/  in /etc??
Title: Re: Probelm with renewing SSL certs
Post by: overseer on May 14, 2025, 09:49:28 PM
Read and follow certbot's documentation. https://certbot.eff.org/instructions?ws=apache&os=snap (https://certbot.eff.org/instructions?ws=apache&os=snap)
You should run certbot from the CLI manually once to set it up, then edit the config to switch to DNS mode.
Code: [Select]
sudo certbot --apacheMy example was specifically for Cloudflare, so you may have to adapt it to your situation.
Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 19, 2025, 04:27:42 PM
Hi, thanks by your reply..... Now, when I run the command that you suggested to me, I get:

 sudo certbot --apache
/opt/certbot/lib64/python3.6/site-packages/OpenSSL/_util.py:6: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
  from cryptography.hazmat.bindings.openssl.binding import Binding
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Python 3.6 support will be dropped in the next release of Certbot - please upgrade your Python version.
The apache plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError('Cannot find Apache executable httpd',)
[root@mail ~]#

I have AlmaLinux 8 ... Please your help... Regards..
Title: Re: Probelm with renewing SSL certs
Post by: Netino on May 20, 2025, 02:37:33 AM
Try to repair and create a new configuration with run the following script(still working with acme.sh):
Code: [Select]
#!/bin/bash

DOM=${1}
WEBS=""
systemctl -q is-active nginx && WEBS="${WEBS} nginx"
systemctl -q is-active httpd && WEBS="${WEBS} httpd"

/root/.acme.sh/acme.sh --cert-home /root/.acme.sh/cwp_certs --webroot /usr/local/apache/autossl_tmp --issue -d ${DOM} mail webmail ftp cpanel --ecc \
  --cert-file /etc/pki/tls/certs/${DOM}.cert \
  --key-file  /etc/pki/tls/private/${DOM}.key \
  --fullchain-file /etc/pki/tls/certs/${DOM}.bundle \
  --reloadcmd "systemctl restart ${WEBS}"

Run it with:
Code: [Select]
# chmod script.sh
# ./script.sh your-domain.com

After that, try to renew with CWP (because CWP still could claim the domain have not a cert)
Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 20, 2025, 02:49:45 PM
Hi friend, I get the next when run the script

ot@mail ~]# ./script.sh xxx.com
[Tue May 20 09:48:46 -05 2025] Unknown parameter: mail
Title: Re: Probelm with renewing SSL certs
Post by: overseer on May 20, 2025, 09:15:24 PM
What SANs do you need for your domain? Netino's script has the basic four used by CWP: mail webmail ftp cpanel (in addition to the common www CNAME, which is included in the main domain). Do you not use the "mail" SAN? Personally, I use the other three, but not cpanel.
Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 21, 2025, 05:24:09 PM
Hi, I use all de subdamains, mail, www, cpanel...
Title: Re: Probelm with renewing SSL certs
Post by: Netino on May 23, 2025, 12:35:48 AM
Hi friend, I get the next when run the script

ot@mail ~]# ./script.sh xxx.com
[Tue May 20 09:48:46 -05 2025] Unknown parameter: mail

This is not a message from acme.sh.
So, may be you copy something wrong in your script.?

Try to replace the parameters directly in the main command in that script (/root/.acme.sh/acme.sh ... )

Type all these commands, step-by-step, in bash from your server:
Code: [Select]
# DOM=xxx.com
# WEBS=""
# systemctl -q is-active nginx && WEBS="${WEBS} nginx"
# systemctl -q is-active httpd && WEBS="${WEBS} httpd"
# /root/.acme.sh/acme.sh --cert-home /root/.acme.sh/cwp_certs --webroot /usr/local/apache/autossl_tmp --issue -d ${DOM} mail webmail ftp cpanel --ecc \
  --cert-file /etc/pki/tls/certs/${DOM}.cert \
  --key-file  /etc/pki/tls/private/${DOM}.key \
  --fullchain-file /etc/pki/tls/certs/${DOM}.bundle \
  --reloadcmd "systemctl restart ${WEBS}"

Alternatively, you can put your parameters between quotation marks, like:
Code: [Select]
# DOM="xxx.com"
(...)
# /root/.acme.sh/acme.sh --cert-home "/root/.acme.sh/cwp_certs" --webroot "/usr/local/apache/autossl_tmp" --issue -d "${DOM}" "mail" "webmail" "ftp" "cpanel" --ecc \
(...)

You can check where are the error, and post here.
Title: Re: Probelm with renewing SSL certs
Post by: cfreire on May 27, 2025, 04:09:05 PM
I tried to execute the command directly, and I get the same error... I attach the output.....

root@mail ~]#
[root@mail ~]#
[root@mail ~]# /root/.acme.sh/acme.sh --cert-home /root/.acme.sh/cwp_certs --webroot /usr/local/apache/autossl_tmp --issue -d xxx.com mail webmail ftp cpanel --ecc   --cert-file /etc/pki/tls/certs/cxxxxx.cert   --key-file  /etc/pki/tls/private/xxxxcom.key   --fullchain-file /etc/pki/tls/certs/xxxxcom.bundle
[Tue May 27 11:01:44 -05 2025] Unknown parameter: mail


[root@mail ~]#
[root@mail ~]# /root/.acme.sh/acme.sh --cert-home /root/.acme.sh/cwp_certs --webroot /usr/local/apache/autossl_tmp --issue -d ${DOM} mail webmail ftp cpanel --ecc   --cert-file /etc/pki/tls/certs/${DOM}.cert   --key-file  /etc/pki/tls/private/${DOM}.key   --fullchain-file /etc/pki/tls/certs/${DOM}.bundle   --reloadcmd "systemctl restart ${WEBS}"
[Tue May 27 11:02:10 -05 2025] Unknown parameter: webmail
Title: Re: Probelm with renewing SSL certs
Post by: Starburst on August 13, 2025, 09:10:43 AM
@Netino

Is there a way to renew all the certificates at once, and not one at a time using your script?
Title: Re: Probelm with renewing SSL certs
Post by: overseer on August 13, 2025, 01:29:28 PM
Seems like you could iterate it in a loop... and set it for interactive use to use $1 as an argument so you can feed in the domain instead of hard-coding it in the script.