Unable to load config info from /usr/local/ssl/openssl.cnf on Windows

WindowsOpensslPublic Key-Encryption

Windows Problem Overview


While using OpenSSL on Windows:

openssl genrsa -out privatekey.pem 1024 -->

Created successfully

openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 365 
---->

Showing error message as

> unable to load config info from /usr/local/ssl/openssl.cnf

Windows Solutions


Solution 1 - Windows

After installing OpenSSL I was required to create a new environment variable:

  • Name: OPENSSL_CONF
  • Value: C:\Program Files\OpenSSL\openssl.cnf

In powershell:

$env:OPENSSL_CONF = "${env:ProgramFiles}\OpenSSL\openssl.cnf"

This value differs from previous installation versions (as seen in a previous edit of this post). Also, don't forget to add the openssl binary folder ${env:ProgramFiles}\OpenSSL to your Path.

Solution 2 - Windows

You should specify the absolute path to the config, something like this:

openssl req -x509 -config "C:\OpenSSL-Win64\bin\openssl.cnf" ...

Solution 3 - Windows

In Windows 10, no need to restart nor run in Administrator's mode but instead set openssl config like so:

set OPENSSL_CONF=C:\Program Files (x86)\GnuWin32\share\openssl.cnf

Of course, if you are using GnuWin32

Solution 4 - Windows

The only thing that worked for me in this situation was the self-created openssl.cnf file.

Here are the basics needed for this exercise (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

I hope that helps.

Solution 5 - Windows

In windows , [Similar scenario]

I was facing the same problem But It was during requesting for Certificate Signing Request.

I did the below , It Worked for me.

Once OpenSSL installed, Ran command prompt as administrator after the system reboot.[for the best I did both.. run as admin and system reboot]

did, 1.[Error Case]

C:\OpenSSL-Win64\bin>openssl req -new -key server.key -out server.csr

WARNING: can't open config file: C:\OpenSSL-Win64\bin\openssl.cnf AND Unable to load config info from C:\OpenSSL-Win64\bin\openssl.cnf

2.[Worked with Warning]

C:\OpenSSL-Win64\bin> openssl req -new -key server.key -out server.csr -config C:\OpenSSL-Win64\bin\openssl.cfg

> [Warning message]: WARNING: can't open config file: C:\OpenSSL-Win64\bin\openssl.cnf

But prompted me for the http://www.akadia.com/services/ssh_test_certificate.html">Pass Phrase for server.key It worked for me.

I referred,This http://www.akadia.com/services/ssh_test_certificate.html">link</a> for my assistance.

Thank you.

Solution 6 - Windows

After installing OpenSSL, you need to restart your computer and use Run As Administrator. Then its works.

Solution 7 - Windows

With the GnuWin32 tools I found the openssl.cnf under C:\gnuwin32\share

set OPENSSL_CONF=C:\gnuwin32\share\openssl.cnf

Solution 8 - Windows

For me on Windows 8, I simply found openssl.cnf file and copied it on the C drive. then:

openssl req -new -key server.key -out server.csr -config C:\openssl.cnf

Worked perfectly.

Solution 9 - Windows

In Windows 7 I didn't have to restart, simply run command prompt in administrator mode.

Solution 10 - Windows

In my case, I need to set the path of openssl.cnf file manually on the command using config option. So the command

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

Solution 11 - Windows

If you're using Win32 OpenSSL v1.1.0g, setting up this environment variable:

set OPENSSL_CONF=C:\OpenSSL-Win32\bin\cnf\openssl.cnf

Before running this command with "server.key", successfully creating "server.csr":

openssl req -new -key server.key -out server.csr

Solution 12 - Windows

On the basic question of why openssl is not found: Short answer:Some installation packages for openssl have a default openssl.cnf pre-included. Other packages do not. In the latter case you will include one from the link shown below; You can enter additional user-specifics --DN name,etc-- as needed.

From https://www.openssl.org/docs/manmaster/man5/config.html,I quote directly:

"OPENSSL LIBRARY CONFIGURATION

Applications can automatically configure certain aspects of OpenSSL using the master OpenSSL configuration file, or optionally an alternative configuration file. The openssl utility includes this functionality: any sub command uses the master OpenSSL configuration file unless an option is used in the sub command to use an alternative configuration file.

To enable library configuration the default section needs to contain an appropriate line which points to the main configuration section. The default name is openssl_conf which is used by the openssl utility. Other applications may use an alternative name such as myapplication_conf. All library configuration lines appear in the default section at the start of the configuration file.

The configuration section should consist of a set of name value pairs which contain specific module configuration information. The name represents the name of the configuration module. The meaning of the value is module specific: it may, for example, represent a further configuration section containing configuration module specific information. E.g.:"

So it appears one must self configure openssl.cnf according to your Distinguished Name (DN), along with other entries specific to your use.

Here is the template file from which you can generate openssl.cnf with your specific entries.

One Application actually has a demo installation that includes a demo .cnf file.

Additionally, if you need to programmatically access .cnf files, you can include appropriate headers --openssl/conf.h-- and parse your .cnf files using

CONF_modules_load_file(const char *filename, const char *appname,
                            unsigned long flags);

Here are docs for "CONF_modules_load_file";

Solution 13 - Windows

On Windows Powershell:

$env:OPENSSL_CONF = "${env:ProgramFiles}\OpenSSL-Win64\bin\openssl.cfg"

Solution 14 - Windows

For me put variable before calling did the trick:

OPENSSL_CONF=/usr/ssl/openssl.cnf openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 365

Solution 15 - Windows

I had similar problem on Windows 7:

WARNING: can't open config file: C:\OpenSSL-Win32\bin\openssl.cfg
Unable to load config info from C:\OpenSSL-Win32\bin\openssl.cfg

The reason was removed OpenSSL-Win32 directory without using deinstallator, so not all components was properly removed from system. I had to remove environment variable OPENSSL_CONF manually.

Some openssl binaries, e.g. installed with git, does not need OPENSSL_CONF environment variable, but if this environment variable exists it must lead to valid file.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkarthikView Question on Stackoverflow
Solution 1 - Windowslame_coderView Answer on Stackoverflow
Solution 2 - Windowszombi_manView Answer on Stackoverflow
Solution 3 - WindowsBlackPearlView Answer on Stackoverflow
Solution 4 - WindowssimhumilecoView Answer on Stackoverflow
Solution 5 - WindowsmavisView Answer on Stackoverflow
Solution 6 - WindowskarthikView Answer on Stackoverflow
Solution 7 - WindowsT LView Answer on Stackoverflow
Solution 8 - WindowsAliView Answer on Stackoverflow
Solution 9 - WindowsCalgary LibertarianView Answer on Stackoverflow
Solution 10 - WindowsSunil GargView Answer on Stackoverflow
Solution 11 - Windows5ervant - techintel.github.ioView Answer on Stackoverflow
Solution 12 - WindowsloveofthecodeView Answer on Stackoverflow
Solution 13 - WindowsSmithView Answer on Stackoverflow
Solution 14 - WindowsVoloshinSView Answer on Stackoverflow
Solution 15 - WindowsololukiView Answer on Stackoverflow