Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenSSL can't find distinguished_name in config file

When attempting to generate a csr via openssl on Windows, I get and error stating "unable to find 'distinguished_name' in config". I have done this previously without issue, but can't seem to figure out why it isn't doing the the thing now.

My config file (request.txt):

[req]
default_bits           = 2048
prompt                 = no
default_md             = sha384
req_extensions         = req_ext
distinguished_name     = req_distinguished_name

[req_distinguished_name]
countryName            = US
stateOrProvinceName    = Nevada
organizationName       = OrgName
organizationalUnitName = DepName
commonName             = <snip-fqdn>
emailAddress           = <snip-email>

[req_ext]
subjectAltName         = @alt_names

[alt_names]
DNS.1                  = <snip-fqdn1>
DNS.2                  = <snip-fqdn2>
IP.1                   = <snip-ip>

The command I am using to generate the csr (OpenSSL is a PowerShell alias to openssl.exe):

OpenSSL req -newkey rsa:2048 -keyout key.pem -nodes -out request.csr -config request.txt

This results in an error stating the distinguished_name cannot be found in the config:

req: Error on line 1 of config file "H:\path\to\request.txt"
Generating a RSA private key
................+++++
..........+++++
writing new private key to 'H:\path\to\key.pem'
-----
unable to find 'distinguished_name' in config
problems making Certificate Request
3252:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or environment variable:crypto\conf\conf_lib.c:270:

The distinguished_name is defined in the config, so I am unsure what openssl is on about here. I am truly at a loss with this one. Any ideas?

like image 293
EmmaRenee19 Avatar asked Jul 11 '19 14:07

EmmaRenee19


People also ask

Where is OpenSSL CNF in Windows?

OpenSSL for Windows has now been installed and can be found as OpenSSL.exe in C:\OpenSSL-Win32\bin\.

Where is OpenSSL CFG?

The directory for all OpenSSL certificates is /var/ssl/. All commands and paths in this document are issued from this directory, it is not mandatory but it will help the examples. OpenSSL by default looks for a configuration file in /usr/lib/ssl/openssl.

What is OpenSSL CNF?

The openssl. cnf file is primarily used to set default values for the CA function, key sizes for generating new key pairs, and similar configuration. Consult the OpenSSL documentation available at openssl.org for more information.


Video Answer


1 Answers

It looks like this is your real error:

req: Error on line 1 of config file "H:\path\to\request.txt"

This might be caused because of a weird character or space in the first line of the requests.txt file.

like image 175
Jason Alan Hurst Avatar answered Nov 15 '22 10:11

Jason Alan Hurst