Skip to main content

cPanel SSL certs + Let's Encrypt

Comments

9 comments

  • cPanelMichael
    Hello :) Replacing the data populated in those files should be all that's required. There's no script you need to run after manually updated those files. Please note this thread: [How-To] Installing SSL from Let's Encrypt Thank you.
    0
  • Arvy
    Hi Michael, yes, I already have Let's Encrypt working. The link is more for installing SSL on domains (HTTPS). Can you confirm if I write my own script to recreate certificate files every 60 days for each service (exim/dovecot/pureftp/cpanel) and restart them, based on files regenerated by each run of Let's Encrypt script, if cPanel will not alert me about expiration from the data generated last time I used WHM to manipulate the certificates? Means, if I work with the certificates directly, cPanel will not break or something, right? Thanks!
    0
  • Arvy
    Ok, after testing a lot, I did a script to use Let's Encrypt certificates to cPanel services. NOTES: - I did for CentOS 6. For CentOS 7 or other Systemd, need to change "services" to proper "systemctl" - need to pre-install Let's Encrypt and run once to do the first basic configuration - script will back up previous certs on /root/ssl - chown is not really needed, just to be sure the owner is ok
    CRON:
    5 0 */75 * 6 /root/updcerts
    Will update every 75 days, only on saturdays SCRIPT:
    #!/bin/bash /opt/letsencrypt/letsencrypt-auto --debug certonly -a webroot --agree-tos --webroot-path=/usr/local/apache/htdocs --renew-by-default -d $HOSTNAME /bin/mkdir /root/ssl \cp -f /var/cpanel/ssl/cpanel/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem /etc/letsencrypt/live/$HOSTNAME/cert.pem > /var/cpanel/ssl/cpanel/cpanel.pem /bin/chown cpanel:cpanel /var/cpanel/ssl/cpanel/cpanel.pem /sbin/service cpanel restart \cp -f /var/cpanel/ssl/exim/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem > /var/cpanel/ssl/exim/exim.key /bin/cat /etc/letsencrypt/live/$HOSTNAME/cert.pem > /var/cpanel/ssl/exim/exim.crt /bin/chown mailnull:mail /var/cpanel/ssl/exim/exim.* /sbin/service exim restart \cp -f /var/cpanel/ssl/ftp/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem > /var/cpanel/ssl/ftp/ftpd-rsa-key.pem /bin/cat /etc/letsencrypt/live/$HOSTNAME/cert.pem > /var/cpanel/ssl/ftp/ftpd-rsa.pem /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem /etc/letsencrypt/live/$HOSTNAME/cert.pem > /var/cpanel/ssl/ftp/pure-ftpd.pem /bin/chown root:wheel /var/cpanel/ssl/ftp/* /sbin/service pure-ftpd restart \cp -f /var/cpanel/ssl/dovecot/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem > /var/cpanel/ssl/dovecot/dovecot.key /bin/cat /etc/letsencrypt/live/$HOSTNAME/cert.pem > /var/cpanel/ssl/dovecot/dovecot.crt /bin/chown root:wheel /var/cpanel/ssl/dovecot/dovecot.* /sbin/service dovecot restart
    Any suggestions, errors detected, ideas? Thanks.
    0
  • cPanelMichael
    Can you confirm if I write my own script to recreate certificate files every 60 days for each service (exim/dovecot/pureftp/cpanel) and restart them, based on files regenerated by each run of Let's Encrypt script, if cPanel will not alert me about expiration from the data generated last time I used WHM to manipulate the certificates? Means, if I work with the certificates directly, cPanel will not break or something, right?

    Yes, this should work as you expect it to. cPanel will not automatically overwrite these files before a 60-day window. Thank you.
    0
  • Arvy
    Here is my script, updated. Hope helps who wants to use LE's certs to basic cPanel services. You need to download the CA:
    wget https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem mv lets-encrypt-x1-cross-signed.pem /etc/letsencrypt/live/$HOSTNAME/ca.pem
    New version will append CA to the certificates to be more compatible.
    #!/bin/bash /opt/letsencrypt/letsencrypt-auto --debug certonly -a webroot --agree-tos --webroot-path=/usr/local/apache/htdocs --renew-by-default -d $HOSTNAME /bin/mkdir /root/ssl \cp -f /var/cpanel/ssl/cpanel/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem /etc/letsencrypt/live/$HOSTNAME/cert.pem /etc/letsencrypt/live/$HOSTNAME/ca.pem > /var/cpanel/ssl/cpanel/cpanel.pem /bin/chown cpanel:cpanel /var/cpanel/ssl/cpanel/cpanel.pem /sbin/service cpanel restart /sbin/service httpd restart \cp -f /var/cpanel/ssl/exim/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem > /var/cpanel/ssl/exim/exim.key /bin/cat /etc/letsencrypt/live/$HOSTNAME/cert.pem /etc/letsencrypt/live/$HOSTNAME/ca.pem > /var/cpanel/ssl/exim/exim.crt /bin/chown mailnull:mail /var/cpanel/ssl/exim/exim.* /sbin/service exim restart \cp -f /var/cpanel/ssl/ftp/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem > /var/cpanel/ssl/ftp/ftpd-rsa-key.pem /bin/cat /etc/letsencrypt/live/$HOSTNAME/cert.pem /etc/letsencrypt/live/$HOSTNAME/ca.pem > /var/cpanel/ssl/ftp/ftpd-rsa.pem /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem /etc/letsencrypt/live/$HOSTNAME/cert.pem /etc/letsencrypt/live/$HOSTNAME/ca.pem > /var/cpanel/ssl/ftp/pure-ftpd.pem /bin/chown root:wheel /var/cpanel/ssl/ftp/* /sbin/service pure-ftpd restart \cp -f /var/cpanel/ssl/dovecot/* /root/ssl/ /bin/cat /etc/letsencrypt/live/$HOSTNAME/privkey.pem > /var/cpanel/ssl/dovecot/dovecot.key /bin/cat /etc/letsencrypt/live/$HOSTNAME/cert.pem /etc/letsencrypt/live/$HOSTNAME/ca.pem > /var/cpanel/ssl/dovecot/dovecot.crt /bin/chown root:wheel /var/cpanel/ssl/dovecot/dovecot.* /sbin/service dovecot restart
    Note, again: this is for CentOS 6-. Change as needed for other systems, or CentOS 7 (systemd).
    0
  • ChristianSB
    Do you have a version there works on CentOS 7 running DNS Only? :)
    0
  • nimonogi
    Do you have a version there works on CentOS 7 running DNS Only? :)

    I'm looking for the exact same thing.
    0
  • cPanelMichael
    Do you have a version there works on CentOS 7 running DNS Only? :)

    Could you elaborate on what in-particular is not working on the DNS-Only server when using this custom application? Thank you.
    0
  • BlackRain
    I bit the bullet and bought the Cpanel app for Lets Encrypt and it has worked seamlessly for awhile now.
    0

Please sign in to leave a comment.