cannot load certificate “/usr/local/nginx/ssl/*.pem“: BIO_new_file() failed

这篇具有很好参考价值的文章主要介绍了cannot load certificate “/usr/local/nginx/ssl/*.pem“: BIO_new_file() failed。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

最近部署SSL证书的时候老是报错, cannot load certificate "/usr/local/nginx/ssl/*.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/usr/local/nginx/ssl/*.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

这个错误也是比较常见的,我出现这个问题首先是查看自己路径下有没有这个文件,排查之后发现确实有这个文件,重启之后还是报这个错误,那这个原因可能是docker部署nginx时挂载目录出现了错误,

docker inspect nginx

往下找

cannot load certificate “/usr/local/nginx/ssl/*.pem“: BIO_new_file() failed

这里没错,那估计是nginx自身的问题

快速用docker部署一个nginx,

docker pull nginx
#部署nginx
docker run -d -p 80:80 --name=nginx --privileged=true nginx
#进入容器内部
docker exec -it nginx /bin/bash

进入容器内部后查看nginx的配置SSL文件的要求

cd /etc
#显示文件
ls 

cannot load certificate “/usr/local/nginx/ssl/*.pem“: BIO_new_file() failed

 文章来源地址https://www.toymoban.com/news/detail-505822.html

cat ca-certificates.conf
# This file lists certificates that you wish to use or to ignore to be
# installed in /etc/ssl/certs.
# update-ca-certificates(8) will update /etc/ssl/certs by reading this file.
#
# This is autogenerated by dpkg-reconfigure ca-certificates.
# Certificates should be installed under /usr/share/ca-certificates
# and files with extension '.crt' is recognized as available certs.
#
# line begins with # is comment.
# line begins with ! is certificate filename to be deselected.
#
mozilla/ACCVRAIZ1.crt
mozilla/AC_RAIZ_FNMT-RCM.crt
mozilla/Actalis_Authentication_Root_CA.crt
mozilla/AffirmTrust_Commercial.crt
mozilla/AffirmTrust_Networking.crt
mozilla/AffirmTrust_Premium.crt
mozilla/AffirmTrust_Premium_ECC.crt
mozilla/Amazon_Root_CA_1.crt
mozilla/Amazon_Root_CA_2.crt
mozilla/Amazon_Root_CA_3.crt
mozilla/Amazon_Root_CA_4.crt
mozilla/Atos_TrustedRoot_2011.crt
mozilla/Autoridad_de_Certificacion_Firmaprofesional_CIF_A62634068.crt
mozilla/Baltimore_CyberTrust_Root.crt
mozilla/Buypass_Class_2_Root_CA.crt
mozilla/Buypass_Class_3_Root_CA.crt
mozilla/CA_Disig_Root_R2.crt
mozilla/CFCA_EV_ROOT.crt
mozilla/COMODO_Certification_Authority.crt
mozilla/COMODO_ECC_Certification_Authority.crt
mozilla/COMODO_RSA_Certification_Authority.crt
mozilla/Certigna.crt
mozilla/Certigna_Root_CA.crt
mozilla/Certum_Trusted_Network_CA.crt
mozilla/Certum_Trusted_Network_CA_2.crt
mozilla/Chambers_of_Commerce_Root_-_2008.crt
mozilla/Comodo_AAA_Services_root.crt
mozilla/Cybertrust_Global_Root.crt
mozilla/D-TRUST_Root_Class_3_CA_2_2009.crt
mozilla/D-TRUST_Root_Class_3_CA_2_EV_2009.crt
mozilla/DST_Root_CA_X3.crt
mozilla/DigiCert_Assured_ID_Root_CA.crt
mozilla/DigiCert_Assured_ID_Root_G2.crt
mozilla/DigiCert_Assured_ID_Root_G3.crt
mozilla/DigiCert_Global_Root_CA.crt
mozilla/DigiCert_Global_Root_G2.crt
mozilla/DigiCert_Global_Root_G3.crt
mozilla/DigiCert_High_Assurance_EV_Root_CA.crt
mozilla/DigiCert_Trusted_Root_G4.crt
mozilla/E-Tugra_Certification_Authority.crt
mozilla/EC-ACC.crt
mozilla/Entrust.net_Premium_2048_Secure_Server_CA.crt
mozilla/Entrust_Root_Certification_Authority.crt
mozilla/Entrust_Root_Certification_Authority_-_EC1.crt
mozilla/Entrust_Root_Certification_Authority_-_G2.crt
mozilla/Entrust_Root_Certification_Authority_-_G4.crt
mozilla/GDCA_TrustAUTH_R5_ROOT.crt
mozilla/GTS_Root_R1.crt
mozilla/GTS_Root_R2.crt
mozilla/GTS_Root_R3.crt
mozilla/GTS_Root_R4.crt
mozilla/GeoTrust_Primary_Certification_Authority_-_G2.crt
mozilla/GlobalSign_ECC_Root_CA_-_R4.crt
mozilla/GlobalSign_ECC_Root_CA_-_R5.crt
mozilla/GlobalSign_Root_CA.crt
mozilla/GlobalSign_Root_CA_-_R2.crt
mozilla/GlobalSign_Root_CA_-_R3.crt
mozilla/GlobalSign_Root_CA_-_R6.crt
mozilla/Global_Chambersign_Root_-_2008.crt
mozilla/Go_Daddy_Class_2_CA.crt
mozilla/Go_Daddy_Root_Certificate_Authority_-_G2.crt
mozilla/Hellenic_Academic_and_Research_Institutions_ECC_RootCA_2015.crt
mozilla/Hellenic_Academic_and_Research_Institutions_RootCA_2011.crt
mozilla/Hellenic_Academic_and_Research_Institutions_RootCA_2015.crt
mozilla/Hongkong_Post_Root_CA_1.crt
mozilla/Hongkong_Post_Root_CA_3.crt
mozilla/ISRG_Root_X1.crt
mozilla/IdenTrust_Commercial_Root_CA_1.crt
mozilla/IdenTrust_Public_Sector_Root_CA_1.crt
mozilla/Izenpe.com.crt
mozilla/Microsec_e-Szigno_Root_CA_2009.crt
mozilla/Microsoft_ECC_Root_Certificate_Authority_2017.crt
mozilla/Microsoft_RSA_Root_Certificate_Authority_2017.crt
mozilla/NAVER_Global_Root_Certification_Authority.crt
mozilla/NetLock_Arany_=Class_Gold=_Főtanúsítvány.crt
mozilla/Network_Solutions_Certificate_Authority.crt
mozilla/OISTE_WISeKey_Global_Root_GB_CA.crt
mozilla/OISTE_WISeKey_Global_Root_GC_CA.crt
mozilla/QuoVadis_Root_CA.crt
mozilla/QuoVadis_Root_CA_1_G3.crt
mozilla/QuoVadis_Root_CA_2.crt
mozilla/QuoVadis_Root_CA_2_G3.crt
mozilla/QuoVadis_Root_CA_3.crt
mozilla/QuoVadis_Root_CA_3_G3.crt
mozilla/SSL.com_EV_Root_Certification_Authority_ECC.crt
mozilla/SSL.com_EV_Root_Certification_Authority_RSA_R2.crt
mozilla/SSL.com_Root_Certification_Authority_ECC.crt
mozilla/SSL.com_Root_Certification_Authority_RSA.crt
mozilla/SZAFIR_ROOT_CA2.crt
mozilla/SecureSign_RootCA11.crt
mozilla/SecureTrust_CA.crt
mozilla/Secure_Global_CA.crt
mozilla/Security_Communication_RootCA2.crt
mozilla/Security_Communication_Root_CA.crt
mozilla/Sonera_Class_2_Root_CA.crt
mozilla/Staat_der_Nederlanden_EV_Root_CA.crt
mozilla/Staat_der_Nederlanden_Root_CA_-_G3.crt
mozilla/Starfield_Class_2_CA.crt
mozilla/Starfield_Root_Certificate_Authority_-_G2.crt
mozilla/Starfield_Services_Root_Certificate_Authority_-_G2.crt
mozilla/SwissSign_Gold_CA_-_G2.crt
mozilla/SwissSign_Silver_CA_-_G2.crt
mozilla/T-TeleSec_GlobalRoot_Class_2.crt
mozilla/T-TeleSec_GlobalRoot_Class_3.crt
mozilla/TUBITAK_Kamu_SM_SSL_Kok_Sertifikasi_-_Surum_1.crt
mozilla/TWCA_Global_Root_CA.crt
mozilla/TWCA_Root_Certification_Authority.crt
mozilla/TeliaSonera_Root_CA_v1.crt
mozilla/TrustCor_ECA-1.crt
mozilla/TrustCor_RootCert_CA-1.crt
mozilla/TrustCor_RootCert_CA-2.crt
mozilla/Trustis_FPS_Root_CA.crt
mozilla/Trustwave_Global_Certification_Authority.crt
mozilla/Trustwave_Global_ECC_P256_Certification_Authority.crt
mozilla/Trustwave_Global_ECC_P384_Certification_Authority.crt
mozilla/UCA_Extended_Validation_Root.crt
mozilla/UCA_Global_G2_Root.crt
mozilla/USERTrust_ECC_Certification_Authority.crt
mozilla/USERTrust_RSA_Certification_Authority.crt
mozilla/VeriSign_Universal_Root_Certification_Authority.crt
mozilla/XRamp_Global_CA_Root.crt
mozilla/certSIGN_ROOT_CA.crt
mozilla/certSIGN_Root_CA_G2.crt
mozilla/e-Szigno_Root_CA_2017.crt
mozilla/ePKI_Root_Certification_Authority.crt
mozilla/emSign_ECC_Root_CA_-_C3.crt
mozilla/emSign_ECC_Root_CA_-_G3.crt
mozilla/emSign_Root_CA_-_C1.crt
mozilla/emSign_Root_CA_-_G1.crt

这个就是它里面的内容,主要看里面的注释

cannot load certificate “/usr/local/nginx/ssl/*.pem“: BIO_new_file() failed

 cat ca-certificates.conf让我们把证书安装在/etc/ssl/certs目录下,这下之前的问题就说的通了

将自己的证书部署在/etc/ssl/certs目录下就可以了,下面展示我的配置(docker的)

docker run --name nginx -p 80:80 -p 443:443  -v /usr/local/vue:/usr/local/vue -v /usr/local/nginx/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/nginx/logs:/var/log/nginx -v /etc/ssl/certs:/etc/ssl/certs  --privileged=true -d --restart=always nginx

 

这里为了方便直接将挂载目录设置成和nginx内部的一样了,不一样的话,填写pem和key文件的话要安装nginx内部的容器来

        ssl_certificate    /etc/ssl/certs/*.crt;
        ssl_certificate_key  /etc/ssl/certs/*.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

部署完后就可以用https访问你的网址了

 

到了这里,关于cannot load certificate “/usr/local/nginx/ssl/*.pem“: BIO_new_file() failed的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:35

    这个错误提示表明在Nginx配置文件(通常是nginx.conf)中使用了SSL(Secure Sockets Layer)相关的配置,但是Nginx没有加载相应的SSL模块。 1.检查Nginx是否编译了SSL模块: /usr/local/nginx/sbin/nginx -V 21 | grep --color=auto ssl /usr/local/nginx/sbin/nginx:安装nginx的绝对路径 输出以下结果 则为安装已

    2024年03月16日
    浏览(14)
  • nginx启动报错:nginx: [emerg] https protocol requires SSL support in /usr/local/nginx/conf/ngi

    nginx: [emerg] https protocol requires SSL support in /usr/local/nginx/conf/nginx 这个错误是由于配置了https代理但是没有安装ssl模块导致的,只需要按照以下步骤安装ssl模块 查看nginx配置,顺便找到configure文件位置并切换到有这个文件的目录下 修改configure,增加ssl模块 编译并安装 重启nginx即

    2024年02月11日
    浏览(32)
  • 【Bug解决】curl: (77) error setting certificate verify locations: CAfile: ..ssl/cacert.pem

    报错内容: 报错原因: cacert.pem 的寻址路径 CAfile 不对,也就是在该路径下找不到文件。 解决方法: 1、找到你的 cacert.pem 文件所在位置 /path/to/cacert.pem 。如果你没有该证书,可以先在 https://curl.se/ca/cacert.pem 下载,保存在某个目录中。 2、设置环境变量: 将\\\"/path/to/cacert.pem

    2024年02月15日
    浏览(13)
  • SSL certificate problem: unable to get local issuer certificate解决办法

    SSL certificate problem: unable to get local issuer certificate解决办法

    在github上用https克隆代码时报了如下错误 这是由于当你通过HTTPS访问Git远程仓库的时候,如果服务器上的SSL证书未经过第三方机构认证,git就会报错。原因是因为未知的没有签署过的证书意味着可能存在很大的风险。解决办法就是通过下面的命令将git中的sslverify关掉: 然后在

    2024年02月11日
    浏览(20)
  • Git SSL certificate problem: unable to get local issuer certificate

    错误:     Push failed             Unable to access \\\'https://github.com/ttsin/gitTest.git/\\\': SSL certificate problem: unable to get local issuer certificate 你在远程访问GitHub时,出现 这个错误通常表示Git无法验证GitHub的SSL证书,因为缺少本地颁发机构(CA)的根证书。 方法一: 1. 更新Git的CA证书:

    2024年02月14日
    浏览(18)
  • Git Clone 报错 `SSL certificate problem: unable to get local issuer certificate`

    Git Clone 报错 `SSL certificate problem: unable to get local issuer certificate`

    如果您在尝试克隆Git存储库时得到 “SSL certificate problem: unable to get local issuer certificate” 的错误,这意味着Git无法验证远程存储库的SSL证书。如果SSL证书是自签名的,或者SSL证书链有问题,就会发生这种情况。 想要修复这个错误,可以尝试以下解决方案: 一、 禁用SSL验证: 一般

    2024年02月07日
    浏览(53)
  • php出现SSL certificate problem: unable to get local issuer certificate的解决办法

    当在本地使用curl或者一些其它封装好的http类库或组件(如php界 知名的 http客户端 Guzzle)需要访问https时,如果本地没有配置证书,会出现SSL certificate problem: unable to get local issuer certificate的报错信息。 解决办法一(环境配置方面) ①、下载pem文件 ②、将文件拷贝到任意目录

    2024年02月09日
    浏览(18)
  • 解决 cURL error 60: SSL certificate problem: unable to get local issuer certificate

    解决 cURL error 60: SSL certificate problem: unable to get local issuer certificate

    异常抛出 cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) 报错原因:因为没有配置信任的服务器HTTPS验证。默认情况下,cURL被设为不信任任何CAs,因此浏览器无法通过HTTPs访问你服务器。  1.下载证书 2.下载后放入PHP扩展

    2024年02月07日
    浏览(11)
  • Docker容器无法启动 Cannot find /usr/local/tomcat/bin/setclasspath.sh

    Docker容器无法启动 Cannot find /usr/local/tomcat/bin/setclasspath.sh

    报错信息如下 解决办法 权限不够 加上 --privileged 获取最大权限

    2024年02月12日
    浏览(18)
  • Composer出现 SSL certificate problem: unable to get local issuer certificate 报错的解决方法

    Composer出现 SSL certificate problem: unable to get local issuer certificate 报错的解决方法

    Composer出现crul SSL报错的问题是没有安装CA证书导致的!!! 错误信息如下: [ComposerDownloaderTransportException]                                                                                                      curl error 60 while downloading https://repo.packagist.org/package

    2024年02月03日
    浏览(73)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包