หลักการและเหตุผล
การให้บริการ web ให้ปลอดภัยต้องมีการเข้ารหัสข้อมูลโดยเฉพาะ web ที่มีการ log in ด้วย username, password ของ Account หรือบัญชีใด ๆ ซึ่งเทคนิคที่ใช้กันคือ https หรือ http over SSL ซึ่งการจะทำได้นั้นจะต้องมี SSL certificate ที่ออกจากผู้รับรองที่น่าเชื่อถือซึ่งมีค่าใช้จ่าย
Let’s Encrypt เป็นผู้ออกไปรับรอง SSL certificate ที่ใช้งานได้โดยไม่เสียค่าใช้จ่าย แต่ใบรับรองจะมีอายุเพียง 90 วัน ทำให้ต้องใช้เครื่องมือในการต่ออายุใบรับรองแบบอัตโนมัติ
บทความนี้จะนำวิธีการใช้งาน SSL certificate ของ Let’s Encrypt บน web server Apache บน Ubuntu 14.04
ตัวอย่าง Host ที่ใช้ทดสอบ คือ ten.fte.rmuti.ac.th ที่ยังไม่ได้ใส่ SSL
เครื่องมือที่ใช้สำหรับการขอใช้งาน Let’s Encrypt certificate คือ certbot สามารถเข้าไปดูวิธีการติดตั้ง certbot ได้ที่คู่มือการใช้งานบนเว็บไซต์ certbot ในการใช้งานบนระบบปฏิบัติการอื่น
1.ตั้งเครื่องมือตาม cli นี้
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache
2. เริ่มใช้ certbot ในการขอ certificate
sudo certbot –apache certonly
ระบบจะถาม ให้เรากรอกข้อมูล email address และ agreeing to its Terms of Service จากนั้น
ระบบ จะให้เลือก site ที่ activate อยู่ในเครื่อง โดยกดเป็นตัวเลข site ที่เราจำทำ SSL
ในที่นี้เราจะเลือกหมายเลข 5 คือ site ten.fte.rmuti.ac.th
จากนั้น certbot จะทำการสร้าง ssl แล้วเก็บไฟล์ไว้ที่ ตามข้อความในรูป
3.เมื่อเราได้ ไฟล์ ssl เป็นที่เรียบร้อย ขั้นตอนต่อไปคือ การนำคีย์มาใช้งานในส่วนของ apache โดยสร้างไฟลใหม่ ดังตัวอย่าง
sudo nano /etc/apache2/sites-available/web-ten-ssl.conf
******************************************************
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin noc.kkc@rmuti.ac.th
ServerName ten.fte.rmuti.ac.th
<Directory />
Options -Indexes
AllowOverride None
</Directory>
<Directory /home/tenfte/public_html/>
Options -Indexes
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory “/usr/lib/cgi-bin”>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
DocumentRoot /home/tenfte/public_html
ErrorLog ${APACHE_LOG_DIR}/error-ten.log
CustomLog ${APACHE_LOG_DIR}/access-ten.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/ten.fte.rmuti.ac.th/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ten.fte.rmuti.ac.th/privkey.pem
</VirtualHost>
</IfModule>
******************************************************
4.จากนั้นใช้คำสั่ง sudo a2ensite web-ten-ssl.conf และ sudo service apache2 restart
5.เว็บไซต์จะมี https โดยใช้ใบรับรองของ Let’s Encrypt ซึ่งได้รับความเชื่อถือจากทุก browser เช่น google chrome
หรือ FireFox
6.เนื่องจาก Let’s Encryptre เป็น SSL แบบฟรี จึงมีอายุใช้งานเพียงแค่ 90 วัน จึงต้องมีคำสั่งให้ในการ new certificate โดยใช้คำสั่งนี้
sudo certbot renew –dry-run
*เว็บอ้างอิง https://certbot.eff.org/
*เว็บอ้างอิง https://letsencrypt.org/