Lets Encrypt Renew untuk Pengguna Cloudflare

Pada tulisan ini saya ingin menyampaikan cara memperpanjang sertifikat Let's Encrypt bagi pengguna Cloudflare yang memilih Full (strict) untuk komunikasi terenkripsinya (lihat gambar).

Komunikasi Full (strict)

Biasanya perpanjangan (renew) yang dilakukan menggunakan fitur cronjob atau manual pada server sering gagal. Hal tersebut disebabkan alamat IP yang terbaca merupakan alamat IP Cloudflare, bukan alamat IP server. Oleh karena itu, perlu dilakukan perpanjangan sertifikat secara manual ketika batas waktu aktif sertifikat berakhir. Berikut ini adalah langkah-langkah yang perlu dilakukan.

Pengaturan DNS pada Cloudflare #

Ubah pengaturan pada bagian DNS (lihat gambar).

Pengaturan DNS

Non-aktifkan proxy Cloudflare (lihat gambar) agar alamat IP yang terbaca saat proses perpanjangan sertifikat adalah alamat IP server.

Non-aktifkan proxy

Perpanjang Sertifikat Let's Encrypt #

Sebelum Diperpanjang #

Periksa masa aktif sertifikat untuk memastikan bahwa sertifikat sudah tidak aktif.

root@XXX:~# echo | openssl s_client -connect xxx.xxx.xxx.xxx:443 2>/dev/null | openssl x509 -noout -dates
notBefore=May 1 07:01:00 2017 GMT
notAfter=Jul 30 07:01:00 2017 GMT
root@XXX:~#

Proses Perpanjangan #

Lakukan perpanjangan dengan menggunakan command line berikut.

root@XXX:~# letsencrypt -d baha.web.id -d www.baha.web.id -d catatan.baha.web.id -d www.catatan.baha.web.id

Setelah menjalankan command line di atas, akan muncul output sebagai berikut.

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/baha.web.id-0005/fullchain.pem. Your cert
will expire on 2017-10-28. To obtain a new version of the
certificate in the future, simply run Let's Encrypt again.
root@XXX:~#

Konfigurasi File #

Kemudian, ubah konfigurasi SSL pada file-file berikut.

Berikut ini adalah command line yang digunakan untuk mengubah file-file tersebut menggunakan VIM.

root@XXX:~# vim /etc/apache2/sites-available/default-ssl.conf
root@XXX:~# vim /etc/apache2/sites-available/000-default.conf
root@XXX:~# vim /etc/apache2/sites-available/namadomain.com.conf

Ubah bagian yang diperlukan, yaitu:

  1. SSLCertificateFile
  2. SSLCertificateKeyFile
  3. SSLCertificateChainFile

Dalam kasus ini, perubahannya adalah sebagai berikut.

Nama file: default-ssl.conf

# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/letsencrypt/live/baha.web.id-0005/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/baha.web.id-0005/privkey.pem

# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
SSLCertificateChainFile /etc/letsencrypt/live/baha.web.id-0005/chain.pem

Nama file: 000-default.conf dan namadomain.com.conf

SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/baha.web.id-0005/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/baha.web.id-0005/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/baha.web.id-0005/chain.pem

Catatan: kode di atas hanya potongan isi dari masing-masing file, bukan keseluruhan.

Setelah Diperpanjang #

Periksa masa aktif sertifikat untuk memastikan bahwa masa aktif sertifikat sudah diperpanjang.

root@XXX:~# echo | openssl s_client -connect xxx.xxx.xxx.xxx:443 2>/dev/null | openssl x509 -noout -dates
notBefore=Jul 30 10:00:00 2017 GMT
notAfter=Oct 28 10:00:00 2017 GMT
root@XXX:~#

Since you've made it this far, sharing this article on your favorite social media network would be highly appreciated 💖! For feedback, please ping me on Twitter.

Published