unable to load Private Key 6572:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\

1. 问题描述

在win系统下apache部署https的时候需要生成自签名证书(完整部署过程参考:https://www.cnblogs.com/hld123/p/6343437.html), 这时候需要用到openssh,第一步的命令为:

openssl genrsa 1024 >server.key

这时候生成了可以,不过由于系统是win,key的文件格式不是utf-8,所以在第二个命令:openssl req -new -config openssl.cnf -key server.key >server.csr 的时候会报错:

unable to load Private Key 6572:error:0906D06C:PEM routines:PEM_read_bio:no start line:.\crypto\pem\

这是因为key的文件格式不是utf-8造成的。

2. 解决办法

把server.key用notepad++打开,右下角可以看到文件格式:
在这里插入图片描述
点击菜单栏的格式->转为UTF-8无bom编码格式,
在这里插入图片描述
再进行第二部操作:openssl req -new -config openssl.cnf -key server.key >server.csr就不会报错。同样对第二步,第三步的文件都需要进行格式转换。按照参考文章部署就不会出错。

发布了111 篇原创文章 · 获赞 185 · 访问量 312万+

猜你喜欢

转载自blog.csdn.net/jinxiaonian11/article/details/90725566