automated renewal of a letsencrypt certificate failed

หลังจากทดลองใช้ SSL ฟรี! ของ Let’s Encrypt ก็ยังไม่พบปัญหาอะไร จนกระทั่ง renew มันติดปัญหาว่าไม่สามารถต่ออายุอัตโนมัติได้ โดยจะมีอีเมลมาแจ้งก่อน ความว่า

Let’s Encrypt certificate expiration notice
Hello,
Your certificate (or certificates) for the names listed below will expire in 0 days (on 27 May 16 15:27 +0000). Please make sure to renew your certificate before then, or visitors to your website will encounter errors.
{{hostname}}
For any questions or support, please visit https://community.letsencrypt.org/. Unfortunately, we can’t provide support by email.
If you are receiving this email in error, unsubscribe at http://mandrillapp.com/track/unsub.php. (HTTP link, we know. We’re working on it!)
Regards,
The Let’s Encrypt Team

ตามมาด้วย Google Search Console

จากนั้นเว็บก็จะเข้าแบบปกติไม่ได้ ซึ่ง Google Chrome มันจะแจ้งทำนองว่า การเชื่อมต่อที่ไม่ปลอดภัย เป็นหน้าเพจแดงๆ นั่นละ แสดงว่า SSL เรามีปัญหาเสียแล้ว (ลืม capture ไว้ มัวแต่หาวิธี)

ซึ่งก็ลองเข้าไป renew ใหม่ใน DA แล้ว พบปัญหาดังนี้

Setting up certificate for a hostname: {hostname}
Getting challenge for {hostname} from acme-server...
./letsencrypt.sh: line 321: /var/www/html/.well-known/acme-challenge/: Is a directory
./letsencrypt.sh: line 324: [: -ne: unary operator expected
Waiting for domain verification...
rm: cannot remove ‘/var/www/html/.well-known/acme-challenge/’: Is a directory
Challenge is . Details: . Exiting...

วิธีแก้ไข ให้เราเข้าไปแก้ไข script ที่มีข้อบกพร่อง เนื่องจากมันยังเป็น BETA อยู่ โดยเข้าไปที่ไฟล์

/usr/local/directadmin/scripts/letsencrypt.sh

แก้ไขจาก

CHALLENGE="`echo "${RESPONSE}" | egrep -o '{[^{]*"type":"http-01"[^}]*'`"

เป็น

CHALLENGE="`echo "${RESPONSE}" | awk '/"type": "http-01"/,/}/'`"

จากนั้น restart Direct admin ใหม่ ลองลอง renew certificate ใหม่อีกครั้ง

ที่มา: http://forum.directadmin.com/showthread.php?t=53238