แก้ปัญหา Certbot ต่ออายุ SSL Certificate ไม่ได้

ช่วงแรกที่เริ่มใช้งาน Let’s Encrypt บน Ubuntu 20.04 เมื่อติดตั้ง certbot ไปแล้ว โปรแกรมก็จะทำการต่ออายุ ssl certificate ให้อัตโนมัติทุกๆสามเดือน ทำให้ผู้เขียนเกิดความชะล่าใจ ไม่ได้สนใจกับข้อความผิดพลาดที่แจ้ง เตือนบนคอนโซล จนในเวลาต่อมาเว็บไซต์เข้าใช้งานไม่ได้ จึงมาค้นหาสาเหตุ ตอนแรกก็คิดว่าตัวโปรแกรม certbot เองมีปัญหา พยายามติดตั้งใหม่อยู่หลายรอบก็ยังแก้ไขไม่ได้ จึงทดลองติดตั้งเซิร์ฟเวอร์ใหม่แล้วทำ renew ssl ก็ไม่ได้เหมือนกัน จนต้องเลิกใช้ Let’s Encrypt ไปนานเลย

Traceback (most recent call last):
File "/usr/bin/certbot", line 11, in <module>
load_entry_point('certbot==0.40.0', 'console_scripts', 'certbot')()
...
import OpenSSL
File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1571, in X509StoreFlags
NOTIFY_POLICY = _lib.X509_V_FLAG_NOTIFY_POLICY
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_NOTIFY_POLICY'

ตอนหลังมาพบว่าสาเหตุเกิดจากไลบรารี่ openssl บน python ต่างหากที่มีปัญหา ไม่ได้เป็นที่ certbot อย่างที่เข้าใจในตอนแรก วิธีแก้ไขทำดังนี้

# apt remove python3-pip
# wget https://bootstrap.pypa.io/get-pip.py
# python3 get-pip.py

จากนั้นรีบูทเครื่องเซิฟเวอร์ใหม่

# pip install pyopenssl –upgrade
# certbot –apache

Leave a Reply

Your email address will not be published. Required fields are marked *