无法从Windows上的/usr/local/ssl/openssl.cnf加载配置信息

kar*_*hik 176 windows openssl public-key-encryption

在Windows上使用OpenSSL时:

openssl genrsa -out privatekey.pem 1024 -->

创建成功

openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 365 
---->
Run Code Online (Sandbox Code Playgroud)

显示错误消息为

无法从/usr/local/ssl/openssl.cnf加载配置信息

lam*_*der 165

安装OpenSSL后,我需要创建一个新的环境变量:

  • 名称: OPENSSL_CONF
  • 值: C:\Program Files\OpenSSL\openssl.cnf

在powershell中:

$env:OPENSSL_CONF = "${env:ProgramFiles}\OpenSSL\openssl.cnf"
Run Code Online (Sandbox Code Playgroud)

此值与以前的安装版本不同(如此帖子的上一个编辑中所示).另外,不要忘记将openssl二进制文件夹添加${env:ProgramFiles}\OpenSSL到Path.

  • 在版本1.0.1j上,我不得不使用`C:\ OpenSSL-Win32\bin\openssl.cfg`. (16认同)
  • 对于那些已经使用git的人来说,还是`C:\ Program Files(x86)\ Git\ssl\openssl.cfg`. (12认同)
  • 或64位系统中的C:\ OpenSSL-Win64\bin\openssl.cfg (6认同)

zom*_*man 72

您应该指定配置的绝对路径,如下所示:

openssl req -x509 -config "C:\OpenSSL-Win64\bin\openssl.cnf" ...
Run Code Online (Sandbox Code Playgroud)

  • -config C:\ OpenSSL-Win64\bin\openssl.cnf (36认同)
  • 如果您正在使用Git提供的OpenSSL,那么您可以尝试`-config"C:\ Program Files(x86)\ Git\ssl\openssl.cnf"` (9认同)
  • 在从http://slproweb.com/products/Win32OpenSSL.html下载的版本1.0.1e中,安装后只有bin目录中存在`openssl.cfg`文件.但是使用这个文件似乎无论如何都可行. (4认同)
  • openssl:错误:' - config'是无效的命令.你们是怎么设置它的? (2认同)

Bla*_*arl 32

在Windows 10中,无需重新启动也无需在管理员模式下运行,而是设置openssl配置,如下所示:

set OPENSSL_CONF=C:\Program Files (x86)\GnuWin32\share\openssl.cnf
Run Code Online (Sandbox Code Playgroud)

当然,如果你正在使用 GnuWin32


mav*_*vis 20

在Windows中,[ 类似场景 ]

我遇到了同样的问题但是在请求证书签名请求期间.

我做了以下,它为我工作.

一旦安装了OpenSSL,在系统重启后Ran命令提示符作为管理员.[为了最好的我做了两个..运行管理员和系统重启]

做了,1.[错误案例]

C:\OpenSSL-Win64\bin>openssl req -new -key server.key -out server.csr
Run Code Online (Sandbox Code Playgroud)

警告:无法打开配置文件:C:\ OpenSSL-Win64\bin\openssl.cnf并且无法从C:\ OpenSSL-Win64\bin\openssl.cnf加载配置信息

2. [使用警告]

C:\OpenSSL-Win64\bin> openssl req -new -key server.key -out server.csr -config C:\OpenSSL-Win64\bin\openssl.cfg
Run Code Online (Sandbox Code Playgroud)

[警告信息]:警告:无法打开配置文件:C:\ OpenSSL-Win64\bin\openssl.cnf

但促使我的密码短语为server.key它的工作对我来说.

我提到了,这个链接供我帮助.

谢谢.


sim*_*eco 15

在这种情况下,唯一对我有用的自创的 openssl.cnf 文件.

以下是此练习所需的基础知识(根据需要进行编辑):

#
# 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
Run Code Online (Sandbox Code Playgroud)

我希望有所帮助.

  • 在尝试了此处列出的所有其他解决方案之后,这个解决方案对我有用。创建配置后(在 openssl.exe 目录中),您可以运行 `openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 365 -config openssl.cnf` (3认同)

kar*_*hik 12

安装OpenSSL后,您需要重新启动计算机并使用Run As Administrator.然后它的作品.


小智 11

使用GnuWin32工具,我在C:\ gnuwin32\share下找到了openssl.cnf

set OPENSSL_CONF=C:\gnuwin32\share\openssl.cnf
Run Code Online (Sandbox Code Playgroud)


Ali*_*Ali 8

对于我在Windows 8上,我只是找到openssl.cnf文件并将其复制到C盘上.然后:

openssl req -new -key server.key -out server.csr -config C:\openssl.cnf
Run Code Online (Sandbox Code Playgroud)

工作得很完美.


小智 6

在Windows 7中,我不必重新启动,只需在管理员模式下运行命令提示符即可.


Sun*_*arg 5

就我而言,我需要使用选项在命令上手动设置openssl.cnf文件的路径config。所以命令

openssl req -x509 -config "C:\Users\sk\Downloads\openssl-0.9.8k_X64\openssl.cnf" -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 900
Run Code Online (Sandbox Code Playgroud)