Mới chuyển một cái cert ssl cho Apache. Người ta đã setup trước ở host chạy IIS rồi nên không liên lạc với nhà cung cấp để tạo lại bộ key mà gởi file cấu hình của IIS cho mình làm luôn.
Sau một hồi tìm trên Google thì cũng ra cách. Dưới đây là cách làm.
- Xuất file cấu hình từ IIS:
- Chạy mmc.exe
- Chọn vào 'Console', sau đó chọn tiếp 'Add/Remove Snap-in'.
- Chọn 'Add', sau đó chọn tiếp 'certificates' và nhấn vào 'Add'.
- Chọn 'Computer Account' và nhấn 'Next'.
- Chọn 'Local Computer' và nhấn 'OK'.
- Nhấn 'Close' sau đó nhấn 'OK'.
- Nhấn dấu [+] ở phần 'Certificates' và chọn 'Personal'.
- Nhấn chuột phải vào chứng chỉ muốn xuất ra và chọn 'All tasks' -> 'Export'.
- Xuất hiện một bảng chỉ dẫn, nhớ chọn cả "private key" và làm theo cho đến khi lưu lại thành file .PFX
- Import vô Apache
# Export the private key file from the pfx file
openssl pkcs12 -in filename.pfx -nocerts -out key.pem
# Export the certificate file from the pfx file
openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem
# This removes the passphrase from the private key so Apache won't
# prompt you for your passphase when it starts
openssl rsa -in key.pem -out server.key - Chép 2 file server.key và cert.pem trên vào thư mục nào Apache có quyền đọc (Ví dụ /etc/cert/). Cấu hình bằng cách sửa file /etc/apache2/conf.d/ssl.conf
SSLCertificateFile /etc/cert/cert.pem
SSLCertificateKeyFile /etc/cert/server.key
Restart lại Apache và tận hưởng :)


Add new comment