Can I concatenate openssl conf files?

Viewed 114

If I have a file (my.cnf) containing

[v3_req]
subjectAltName = @alt_names
[alt-names]
DNS ....
DNS ....

and I concatenate it with openssl.cnf (cat openssl.cnf my.cnf > myopenssl.cnf) will openssl parse the new file and add the subjectAltName = to the earlier [v3_req] section or will it overwrite it (so I lose the previous values in [v3_req])?

1 Answers

On Openssl 1.1.1 you can concatenate and it will merge sections with the same name.

For example, the following configuration will result in a certificate request with basicConstraints = CA:TRUE and all three DNSs: localhost, localhost.localdomain and 127.0.0.1.

...
[ req_ext ]

basicConstraints        = CA:FALSE

[ req_ext ]

basicConstraints        = CA:TRUE
subjectAltName          = @alternate_names

[ alternate_names ]

DNS.1       = localhost
DNS.2       = localhost.localdomain

[ alternate_names ]

DNS.3       = 127.0.0.1
Related