↑↑↑ 点击“Linux运维技术之路”关注,总有一篇文章,触动你的心
一、概述:
客户提交一个证书给我,让帮忙把网站域名都改为HTTPS,但是当修改配置完成后,出现如下错误。
[root@localhost ssl]# usr/local/nginx/sbin/nginx -tnginx: [emerg] PEM_read_bio_X509_AUX("/usr/local/nginx/conf/ssl/server.pem") failed (SSL: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode)nginx: configuration file usr/local/nginx/conf/nginx.conf test failed
错误关键" error:0906D064:PEM routines:PEM_read_bio:bad base64 decode"
二、故障原因:
经过对关键字的排查,SSL证书公钥字符串每隔64个字符需要加一个换行,负责会提示 "error:0906D064:PEM routines:PEM_read_bio:bad base64 decode"
三、解决方法:
出现上述问题的原因,主要是由于客户提交给我的证书不是文件,直接用微信复制给我的内容,现在一般阿里云申请的证书自动生成的文件,直接使用文件就会避免出现这样的错误。
好了,出现错误还是要解决的。
首先,想办法把证书内容转换为每隔64个字符,加一个换行。
1、可以使用如下命令
[root@dataX ~]# fold --helpUsage: fold [OPTION]... [FILE]...Wrap input lines in each FILE (standard input by default), writing tostandard output.Mandatory arguments to long options are mandatory for short options too.-b, --bytes count bytes rather than columns-c, --characters count characters rather than columns-s, --spaces break at spaces-w, --width=WIDTH use WIDTH columns instead of 80--help display this help and exit--version output version information and exit
2、执行语句如下
[root@localhost ssl]# /usr/local/nginx/sbin/nginx -tnginx: [emerg] PEM_read_bio_X509_AUX(“/usr/local/nginx/conf/ssl/server.pem”) failed (SSL: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode)nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed[root@localhost ssl]# fold -w 64 server.pem > server.pem1[root@localhost ssl]# \cp -rf server.pem1 server.pem[root@localhost ssl]# /usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@localhost ssl]# /usr/local/nginx/sbin/nginx -s reload
爱运维^_^爱分享

点个在看少背锅 👇
文章转载自Linux运维技术之路,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




