Hands-on AWS knowledge base for developers Managed Ops
Talk to Us

Nginx: cannot load certificate / PEM_read_bio: no start line

Export PDF Print-friendly layout with a copyright watermark; choose Save as PDF in the print dialog
Nginx: cannot load certificate / PEM_read_bio: no start line — Nginx: cannot load certificate / PEM_read_bio: no start line

原因

nginx -t 报 PEM_read_bio:no start line,说明配置指向的「证书文件」不是合法 PEM:下错了格式(DER/PFX)、文件被截断、或路径指错了文件。

解决

  1. 用文本编辑器打开文件,确认以 -----BEGIN CERTIFICATE----- 开头;
  2. DER 转 PEM:openssl x509 -inform der -in cert.cer -out cert.pem;
  3. PFX 拆出证书:openssl pkcs12 -in a.pfx -clcerts -nokeys -out cert.pem;
  4. 文件损坏时重新用二进制方式传输(scp/sftp)。