A CSR is nothing more than a (signed) proposal of what kind of certificate you want to have. It is actually not really needed to create a certificate, i.e. a certificate could be created completely without having a CSR first.
The CSR proposal contains the public key which should get included into the final certificate and it contains things like subject, subject alternative names etc which propose to add to the certificate too. The CSR is signed with your private key so that the CA can verify that you actually own the private key matching the public key of the certificate.
The CA takes the information from your CSR which it likes when creating a certificate and also adds many information by its own, i.e. not taken from the CSR. It will take the public key from the CSR. The subject it adds to the certificate will probably be based on your CSR proposal, but it might also modify it, add subject alternative names you did not add (i.e. might add www.domain
) and exclude others which you've tried to sneak in etc. It will also add start and expiration time, AIA (like URL for OCSP requests), issuer information, certificate purpose ... - and most of these will not be taken from the original CSR.
Basically I am attempting to act as my own CA using OpenSSL (1.1.0i)
I'm not sure if and how one could use the openssl
tool to create certificate hierarchies without CSR but one can definitely do this with the OpenSSL library. For example I regularly create test certificates with root, intermediate and leaf certificate like this in Perl without needing any CSR:
use strict;
use warnings;
use IO::Socket::SSL::Utils;
my @root = CERT_create(
subject => { CN => 'root' },
CA => 1,
);
PEM_cert2file($root[0],'root-cert.pem');
PEM_key2file($root[1],'root-key.pem');
my @middle = CERT_create(
issuer => \@root,
subject => { CN => 'middle' },
CA => 1,
);
PEM_cert2file($middle[0],'middle-cert.pem');
PEM_key2file($middle[1],'middle-key.pem');
my @leaf = CERT_create(
subject => { CN => 'example.com' },
subjectAltNames => [
[ 'DNS', 'example.com' ],
[ 'DNS', 'www.example.com' ],
[ 'IP', '10.0.3.4' ],
],
purpose => 'server',
issuer => \@middle,
);
PEM_cert2file($leaf[0],'server-cert.pem');
PEM_key2file($leaf[1],'server-key.pem');