Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible making openssl skipping the country/common name prompts?

Tags:

openssl

Is there a way to make openssl skiping the prompts such as

Country Name (2 letter code) [US]: Organization Name (eg, company) [My Company Name LTD.]: Common Name (eg, YOUR name) [something]: 

While creating certificates with

openssl req -config openssl.cnf -new -x509 ... 

given the fact those parameters are provided in the openssl.cnf file

e.g.

countryName         = Country Name (2 letter code) countryName_default     = US countryName_min     = 2 countryName_max     = 2 0.organizationName      = Organization Name (eg, company) 0.organizationName_default  = My Company Name LTD. commonName          = Common Name (eg, YOUR name) commonName_max      = 64 commonName_default      = ${ENV::CN} 
like image 845
Tzury Bar Yochay Avatar asked Nov 10 '11 05:11

Tzury Bar Yochay


People also ask

What is OpenSSL req command?

DESCRIPTION. The req command primarily creates and processes certificate requests in PKCS#10 format. It can additionally create self signed certificates for use as root CAs for example.

What is OpenSSL certificate?

OpenSSL is an open-source command line tool that is commonly used to generate private keys, create CSRs, install your SSL/TLS certificate, and identify certificate information.

What does openssl x509 do?

The x509 command is a multi purpose certificate utility. It can be used to display certificate information, convert certificates to various forms, sign certificate requests like a "mini CA" or edit certificate trust settings. Since there are a large number of options they will split up into various sections.


2 Answers

thanks to @indiv

according to this guide -subj is the way to go, e.g.

-subj '/CN=www.mydom.com/O=My Company Name LTD./C=US' 
like image 136
Tzury Bar Yochay Avatar answered Sep 18 '22 20:09

Tzury Bar Yochay


Another solution consists of using the prompt = no directive in your config file.
See OpenSsl: Configuration file format

prompt

if set to the value no this disables prompting of certificate fields and just takes values from the config file directly. It also changes the expected format of the distinguished_name and attributes sections.

There are two separate formats for the distinguished name and attribute sections.

If the prompt option is set to no then these sections just consist of field names and values: for example,

 CN = My Name  OU = My Organization  emailAddress = [email protected] 

This allows external programs (e.g. GUI based) to generate a template file with all the field names and values and just pass it to req.

Alternatively if the prompt option is absent or not set to no then the file contains field prompting information. It consists of lines of the form:

 fieldName="prompt"  fieldName_default="default field value"  fieldName_min= 2  fieldName_max= 4 
like image 33
VonC Avatar answered Sep 19 '22 20:09

VonC