nginx配置ssl证书时,启动报错,无法找到证书文件,报错日志如下:
2021/11/24 15:52:19 [emerg] 4124#3800: cannot load certificate "E:
ginx-1.21.4\ssl\6667030_xxxx.pem": BIO_new_file() failed (SSL: error:0200107B:system library:fopen:Unknown error:fopen('E:
ginx-1.21.4\ssl\6667030_xxxxxx.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)
2021/11/24 15:53:33 [emerg] 1832#4972: cannot load certificate "E:
ginx-1.21.4\ssl\6667030_xxxx.pem": BIO_new_file() failed (SSL: error:0200107B:system library:fopen:Unknown error:fopen('E:
ginx-1.21.4\ssl\6667030_xxxx.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)
解决方法一:
将E盘的地址路径改成“\\”,之前写的是“ssl_certificate E:\nginx-1.21.4\ssl\6667030_xxxx.pem”,就一直报错
server {
listen 443 ssl;
server_name xxxx;
ssl_certificate E:\\nginx-1.21.4\ssl\6667030_xxxx.pem;
ssl_certificate_key E:\\nginx-1.21.4\ssl\6667030_xxxx.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /api/ {
client_max_body_size 1000m;
alias E:\dev\Server\api/;
index index.html index.htm;
}
}
解决方法二:
可以查看log日志,其实日志里已经说明了原因,仔细查看一下路径,应该是\n被转义了,特别是整个路径里有带\n的都会被转义,比如D:\dev\server\nigix\nginx-1.16 就会出现这个问题,日志里会记录:D:\dev\serverigixginx-1.16,无法加载证书。
因此需要更改路径地址,或者双斜杠。
标签:6667030,xxxx,pem,ssl,报错,error,1.21,fopen From: https://blog.51cto.com/u_15898776/5902190