Five days ago we had to renew a number of SSL certificates using free Let’s Encrypt SSL authority to a few Apache servers which were installed in Jelastic PaaS environment. The Apache servers were installed in an environment where:
-
We did have SSH access.
-
We did not have any root privileges or sudo command permission.
-
The SSH access was done using a limited
apacheuser. -
The underlying operating system was CentOS release 6.6 (Final) . (found out about it by running:
cat /etc/centos-release)
Thus we could not use the official Let’s Encrypt client as it requires root privileges. After 3 hours of searching and striving to use multiple client implementations, we stumbled upon letsencrypt.sh. With the guidance of a tutorial written in German!! we finally managed to create our SSL certificates. So today, at last, we will show you how!!!
In this example, we assume that our domain name is bobos.org. We want to create a certificate for bobos.org and www.bobos.org. Note that Let’s Encrypt does not generate wildcard certificates yet!!.
Prerequisites
-
No root access or sudo is required.
-
We Obtain an A record for bobos.org and www.bobos.org which points to the IP of the server you are using.
-
Inside the aforementioned server we have to run a web server which listens to port 80. Listening to port 443 is optional.
-
Shell access to the server.
If you want to have a thourough understanding of why we are going to perform the following steps, you can refer to How it works official article. Few! It is high time we started. Shall we?
- Know thy environment.
- Clone letsecrypt.sh script.
- Configure the script.
- Configure your web server.
- Run the script.
- Find the certificates.
- Configure your web server to use the certificates
- Upload SSL certificates to Jelastic Administration Panel
- Reload or restart web server and test configuration
Know thy environment
After login via SSH we are in /var/www/ directory:
|
|
Then we check CentOS version, because we can!
|
|
Clone letsecrypt.sh script
While being in that directory we clone letsencrypt.sh:
|
|
Configure the script
Then, we have perform a little configuration so the script is aware of our environment and the domains for which we want to generate free SSL certificates:
- Prepare
baseandconfdirectories:1 2 3 4apache@apache2 ~/letsencrypt.sh $ mkdir conf apache@apache2 ~/letsencrypt.sh $ mkdir base apache@apache2 ~/letsencrypt.sh $ cp config.sh.example conf/config.sh apache@apache2 ~/letsencrypt.sh $ cp domains.txt.exampleconfig.sh.example conf/domains.txt - Edit configuration in
/var/www/letsencrypt.sh/conf/config.sh:1 2 3 4CONFIG_D="/var/www/letsencrypt.sh" BASEDIR="/var/www/letsencrypt.sh/base" WELLKNOWN="${BASEDIR}/.acme-challenges" CONTACT_EMAIL="[email protected]" - Add the domain names in /var/www/letsencrypt.sh/conf/domains.txt```:
1bobos.org www.bobos.org
Configure your web server
Now we have to put the following lines in your site’s special apache conf i.e. /etc/httpd/sites-available/bobos.conf or in /etc/httpd/conf/httpd.conf. This will help Let’s Encrypt to access your server, perform domain validation and perform some challenges in order to generate our SSL certificate.
|
|
Run the script
|
|
Find the certificates
The certificates are created in $BASE/certs// directory:
|
|
Configure your web server to use the certificates
Configure Apache in order to use the created certificates. It might by your site’s special conf i.e. /etc/httpd/sites-available/bobos.conf or global /etc/httpd/conf/httpd.conf:
|
|
IMPORTANT NOTE!! The previous configuration will not work in Jelastic Paas environment, as it forces us to add the certificates via Jelastic Administration Panel. Jelastic puts the certificates to /var/lib/jelastic/SSL.
|
|
Upload SSL certificates to Jelastic Administration Panel
Then we have to upload SSL certificates to Jelastic Administration Panel. To achieve that you can use this guide. Otherwise (i.e. putting files via SSH) it will not work.
Reload or restart web server and test configuration
Finally we reload sudo /etc/init.d/apache2 reload or restart (sudo /etc/init.d/apache2 restart) Apache web server and verify that https://bobos.org works.
That is all folks! Greetings from a hot and striving for the best Greece!