These Instructions are for an ubuntu installation with nginx as the server. This method enables a user to get (free) certificates from an opensource provider and requires the website name to be publicly accessible. These instructions may not be applicable in other environments. Follow all applicable certificate policies when installing.

Before obtaining the certificates ensure that there are two DNS A record for the website name (i.e. demonodepublicdns). 

Getting the Certificates (letsencrypt example):

root@ubuntu:~# sudo apt-get update
root@ubuntu:~# sudo apt-get -y install nginx
root@ubuntu:~# wget https://dl.eff.org/certbot-auto
root@ubuntu:~# chmod a+x certbot-auto
root@ubuntu:~# ./certbot-auto
root@ubuntu:~# ./certbot-auto certonly --webroot -w /usr/share/nginx/html -d demonodepublicdns

                                                             ┌────────────────────────────┐
                                                             │ Enter email address (used  │  
                                                             │ for urgent notices and     │  
                                                             │ lost key recovery)         │  
                                                             │ ┌────────────────────────┐ │  
                                                             │ │xxxx@xxxx.xx            │ │  
                                                             │ └────────────────────────┘ │  
                                                             ├────────────────────────────┤  
                                                             │   <  OK  >  <Cancel>       │  
                                                             └────────────────────────────┘                                                                           
                                         ┌───────────────────────────────────────────────────────────────────┐
                                         │ Please read the Terms of Service at                               │  
                                         │ https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. │  
                                         │ You must agree in order to register with the ACME server at       │  
                                         │ https://acme-v01.api.letsencrypt.org/directory                    │  
                                         ├───────────────────────────────────────────────────────────────────┤  
                                         │                   <Agree >          <Cancel>                      │  
                                         └───────────────────────────────────────────────────────────────────┘  

                                                                                                               

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/demonodepublicdns/fullchain.pem. Your cert
   will expire on 2016-09-29. To obtain a new or tweaked version of
   this certificate in the future, simply run letsencrypt-auto again.
   To non-interactively renew *all* of your certificates, run
   "letsencrypt-auto renew"
 - If you like Certbot, please consider supporting our work by:
   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le
root@ubuntu:/opt/letsencrypt# ls /etc/letsencrypt/live/demonodepublicdns/
cert.pem  chain.pem  fullchain.pem  privkey.pem

         

Renewing the Certificates:

Renewing the Certificates on a DATIM Global

Renewing the Certificates on a DATIM node

Automatic Certificate Renewal:

Automatic certificate renewal uses a cronjob to run the update command twice a day.

     1. Ensure the following command returns successfully. It will not make any changes. It will be used in the cronjob to update the certificate if it is in need of renewal.

user@ls:/var/www# sudo ./certbot-auto --config /etc/letsencrypt/configs/ls.datim4u.org.conf certonly --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Cert not due for renewal, but simulating renewal for dry run
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for cert.test2.ohie.org
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Generating key (4096 bits): /etc/letsencrypt/keys/0009_key-certbot.pem
Creating CSR: /etc/letsencrypt/csr/0009_csr-certbot.pem
IMPORTANT NOTES:
 - The dry run was successful.


     2. Create a bash script to run when a certificate is updated, updating the certificates recorded in the OpenHIM system.

In Progress


     3. Create a bash script which will be run by a cronjob.

#!/bin/bash
## navigate to directory with ./certbot-auto
cd /path/to/certbot-auto
## check if the certificate is expiring soon and renew it if needed
sudo ./certbot-auto --config /etc/letsencrypt/configs/ls.datim4u.org.conf certonly --renew-hook "/etc/certbot_renewal/update_OpenHIM.sh" -n 
		# -n ensures a noninteractive session 
		# --renew-hook command only fires if a certificate is renewed
exit 0


     4. Create a cronjob to run twice a day, once at 1:00 AM and once at 1:00 PM.

0 1,13 * * * /etc/certbot_renewal/renewal_cronjob.sh