windows 警告:无法打开配置文件:./bin/openssl.cnf

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31805763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:11:53  来源:igfitidea点击:

WARNING: can't open config file: ./bin/openssl.cnf

windowsopensslxamppssl-certificate

提问by Somnath

makecert

制作证书

and press enter then this error occurs.

然后按回车,就会出现这个错误。

I tried with solutions provided but that not worked for me.

我尝试使用提供的解决方案,但这对我不起作用。

ex: set OPENSSL_CONF=c:/OpenSSL_Win64/bin/openssl.cnf

例如:设置 OPENSSL_CONF=c:/OpenSSL_Win64/bin/openssl.cnf

<pre>WARNING: can't open config file: ./bin/openssl.cnf
Unable to load config info from ./bin/openssl.cnf
WARNING: can't open config file: ./bin/openssl.cnf
Error opening Private Key privkey.pem
5344:error:02001002:system library:fopen:No such file or directory:.\crypto\bio\
bss_file.c:398:fopen('privkey.pem','rb')
5344:error:20074002:BIO routines:FILE_CTRL:system lib:.\crypto\bio\bss_file.c:40
0:
unable to load Private Key
WARNING: can't open config file: ./bin/openssl.cnf
Loading 'screen' into random state - done
server.csr: No such file or directory
Could Not Find C:\xampp\apache\.rnd
Could Not Find C:\xampp\apache\privkey.pem
Could Not Find C:\xampp\apache\server.csr
The system cannot find the file specified.
The system cannot find the file specified.

-----
Das Zertifikat wurde erstellt.
The certificate was provided.</pre>

回答by Suriyaa

Explaining your problem

解释你的问题

This error occurs mainly on Windows computers when you are using OpenSSL package or the Windows installer!

当您使用 OpenSSL 包或Windows 安装程序时,此错误主要发生在 Windows 计算机上!

The reason is that OpenSSLfailed to locate the openssl.cnffile!

原因是OpenSSL找不到openssl.cnf文件



Step-by-Step instructions

分步说明

I will recommend that you do the following (windows only):

我建议您执行以下操作(仅限 Windows):

  1. Open your command prompt as Administrator(few OpenSSL commands opens in random state), thus when OpenSSL tries to write stuff on your disk it fails.

    • Try this easy and fast method:Open the Run dialog box with Win+R key, type cmdand hit Enter
  2. Now before you run any OpenSSL command type the following:

    set OPENSSL_CONF=c:\[PATH TO YOUR OPENSSL DIRECTORY]\bin\openssl.cfg

    • A sample path is: C:\OpenSSL-Win32\bin\openssl.cfg. For Windows (x64-bit) use C:\OpenSSL-Win64\bin\openssl.cfg!
  1. 以管理员身份打开命令提示符(很少有 OpenSSL 命令以随机状态打开),因此当 OpenSSL 尝试在磁盘上写入内容时它会失败。

    • 试试这个简单快捷的方法:打开运行对话框Win+R 键,输入cmd并点击进入
  2. 现在,在运行任何 OpenSSL 命令之前,键入以下内容:

    set OPENSSL_CONF=c:\[PATH TO YOUR OPENSSL DIRECTORY]\bin\openssl.cfg

    • 示例路径是:C:\OpenSSL-Win32\bin\openssl.cfg. 对于 Windows(x64 位)使用C:\OpenSSL-Win64\bin\openssl.cfg!

After you did this now you are good to go with your OpenSSL stuff. Try openssl versionand the error is gone.

完成此操作后,您就可以开始使用 OpenSSL 的东西了。尝试openssl version,错误消失了。

Remember that everytime you open a command prompt you have to run the above command unless you set this as your environment variable.

请记住,每次打开命令提示符时都必须运行上述命令,除非您将其设置为环境变量。



Solve your problem

解决您的问题

Your problem could be:

你的问题可能是:

  • You set the environment variable into the folder OpenSSL_Win64. It should be maybe in OpenSSL-Win64!
  • You forgot maybe to run the command prompt as a Administrator!
  • You set the environment variable to the file openssl.cnfbut it must be openssl.cfg!
  • 您将环境变量设置到文件夹中OpenSSL_Win64。它应该在OpenSSL-Win64
  • 您可能忘记以管理员身份运行命令提示符!
  • 您将环境变量设置为文件,openssl.cnf但它必须是openssl.cfg


Helpful sites

有用的网站

Read also:

另请阅读:

回答by simhumileco

Manually creating an openssl.cnffile in the correct location can solve the problem.

在正确的位置手动创建openssl.cnf文件可以解决问题。

Hereis a file template (edit as needed):

是一个文件模板(根据需要编辑):

#
# OpenSSL configuration file.
#

# Establish working directory.

dir                 = .

[ ca ]
default_ca              = CA_default

[ CA_default ]
serial                  = $dir/serial
database                = $dir/certindex.txt
new_certs_dir               = $dir/certs
certificate             = $dir/cacert.pem
private_key             = $dir/private/cakey.pem
default_days                = 365
default_md              = md5
preserve                = no
email_in_dn             = no
nameopt                 = default_ca
certopt                 = default_ca
policy                  = policy_match

[ policy_match ]
countryName             = match
stateOrProvinceName         = match
organizationName            = match
organizationalUnitName          = optional
commonName              = supplied
emailAddress                = optional

[ req ]
default_bits                = 1024          # Size of keys
default_keyfile             = key.pem       # name of generated keys
default_md              = md5               # message digest algorithm
string_mask             = nombstr       # permitted characters
distinguished_name          = req_distinguished_name
req_extensions              = v3_req

[ req_distinguished_name ]
# Variable name             Prompt string
#-------------------------    ----------------------------------
0.organizationName          = Organization Name (company)
organizationalUnitName          = Organizational Unit Name (department, division)
emailAddress                = Email Address
emailAddress_max            = 40
localityName                = Locality Name (city, district)
stateOrProvinceName         = State or Province Name (full name)
countryName             = Country Name (2 letter code)
countryName_min             = 2
countryName_max             = 2
commonName              = Common Name (hostname, IP, or your name)
commonName_max              = 64

# Default values for the above, for consistency and less typing.
# Variable name             Value
#------------------------     ------------------------------
0.organizationName_default      = My Company
localityName_default            = My Town
stateOrProvinceName_default     = State or Providence
countryName_default         = US

[ v3_ca ]
basicConstraints            = CA:TRUE
subjectKeyIdentifier            = hash
authorityKeyIdentifier          = keyid:always,issuer:always

[ v3_req ]
basicConstraints            = CA:FALSE
subjectKeyIdentifier            = hash

回答by Jose Gomez

When install the application penSSL_Win64, will be located in C:\Program Files\OpenSSL-Win64 so , you need to set to this path with a console command and write: set OPENSSL_CONF=C:\Program Files\OpenSSL-Win64\bin\openssl.cfg

安装应用penSSL_Win64时,会位于C:\Program Files\OpenSSL-Win64,所以需要用console命令设置到这个路径写: set OPENSSL_CONF=C:\Program Files\OpenSSL-Win64\bin\配置文件