Solved Restore SSL certificate for user domain from /usr/local/directadmin/data/.lego folder

MaXi32

Verified User
Joined
Jul 25, 2016
Messages
657
Location
The Earth
Normally, to restore SSL certificate for the user domain I will do the normal DA backup from GUI and restore the user profile and this will also restore SSL certificate. But let say that I only have the certificate file that I got from .lego backup (this was recommended from letsencrypt to do backup on this folder after successfully requesting SSL certificate) but I found no tutorial or documentation on how do we restore this certificate for the user domain using files from this .lego folder (/usr/local/directadmin/data/.lego).

At this point (to help others) I know how to restore the hostname (or server-wide) SSL certificate from this .lego folder and there is a nice script from Poralix (@zEitEr) that is also able to automate this process: https://github.com/poralix/directadmin-utils/blob/master/ssl/install_server_wide_cert.sh

For example in /usr/local/directadmin/data/.lego/certificates let say the hostname is myserver.domain.com so normally it contains these 3 specific files:

Code:
myserver.domain.com.crt
myserver.domain.com.issuer.crt
myserver.domain.com.key

So, if you want to restore the certificate for myserver.domain.com certificate without having to request SSL cert again you will execute this

Code:
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/ssl/install_server_wide_cert.sh
chmod +x install_server_wide_cert.sh
# Usage: ./install_server_wide_cert.sh <PATH_TO_CERT> <PATH_TO_KEY> [<PATH_TO_CACERT>]
./install_server_wide_cert.sh myserver.domain.com.crt myserver.domain.com.key myserver.domain.com.issuer.crt

This is working fine for hostname but is there a documented step that is able to restore this certificate for user domains from .lego folder? I think this should be documented somewhere.
 
Last edited:
It's ok successfully wrote a script to restore this cert from lego file (included in the automation script) here:


The function is inside configure_da_user_domain_ssl ()

The script was based on the guide from custom/letsencrypt.sh and http://files.directadmin.com/services/all/letsencrypt/autoletsencrypt.sh

Thanks.
 
Back
Top