I like to create my own PKI with a root CA and a intermediate CA finally signing a server certificate. For creation of the certificates I used openssl and got these:
cert.pem
-----BEGIN CERTIFICATE-----
MIIFiTCCA3ECAQIwDQYJKoZIhvcNAQENBQAwgY8xCzAJBgNVBAYTAkRFMRYwFAYD
VQQIDA1OaWVkZXJzYWNoc2VuMRMwEQYDVQQHDApPc25hYnJ1ZWNrMRcwFQYDVQQK
DA5NeUNvbXBhbnkgR21iSDEbMBkGA1UECwwSR2VzY2hhZWZ0c2Z1ZWhydW5nMR0w
GwYDVQQDDBRNeUNvbXBhbnkgcHJpbWFyeSBDQTAeFw0yMjEyMTQwODI1MTdaFw0y
MzEyMTQwODI1MTdaMIGEMQswCQYDVQQGEwJERTEWMBQGA1UECAwNTmllZGVyc2Fj
aHNlbjETMBEGA1UEBwwKT3NuYWJydWVjazEXMBUGA1UECgwOTXlDb21wYW55IEdt
YkgxGzAZBgNVBAsMEkdlc2NoYWVmdHNmdWVocnVuZzESMBAGA1UEAwwJbG9jYWxo
b3N0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA51Lmf2dg3YG7wPdH
lhamw49sHkdf5R/LU0bF7MExwCjhQ010Fk4kwsTPVgNv3nc4TS2l2pVIIldoUdY9
2SNO4QWA3CyrvRF34aKJMnIMGTKelm8scwnZEU09jYUQ9ZkZYkNkvkEsAJ/L45SC
arW0lHEheAzC9vQSF6y4SBvQmUzUShEfvrN6FLRkCOYYbAQmULI/PsYzTWLyHTJq
A5meTEWFHSbGldUtTqdC7h/RywEL1ylTrgn15M6Pc1WtGI FkLJGse9UKtwU9Gpx
k35QFnNMMms4Ksq0ESHLi/33zRL6A8 IIrrfLnCQwRsAAmY/ZOxi7RwL4W71rMSW
8SCV4hcjNt2I8cFHZZ3Oe0 R9yGfkYNo6nq5XgDdpz0wtQp2oydeEF8wsJxHe1z8
d6HMeKIWpVuCAgol68Ck lCF6mrMSpSg/ZdnxCfEkWXYZ6Z9ygW3hjgylOxLQWG8
ePXEYLB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xOedY
U9z7oA2lmzyoAFDn4Sz3/hfSQEJ3OcwvIUZK/pIPKvQKpEgZkcRFNZ6DWR0dp6Oh
m2YMfscYBANmJFlk0uCwHtb39r0ZYCmlXVurHi2swWmhzD2jr54YjXK g6FN5Z7P
AVhKrXtTFKoP4gdeKaSqtu/7A Hwl6pl4hp4gKXnfh4hc2s7ZVRmYQNh9joyAFs8
9E oe/qRrYE78PF9ndCXVkWvzFMJ9iKGhrwAhg==
-----END CERTIFICATE-----
Verifing these via openssl results in
.\openssl.exe verify -show_chain -CAfile root_cert.pem -untrusted ca_cert.pem cert.pem
cert.pem: OK
Chain:
depth=0: C = DE, ST = Niedersachsen, L = Osnabrueck, O = MyCompany GmbH, OU = Geschaeftsfuehrung, CN = localhost (untrusted)
depth=1: C = DE, ST = Niedersachsen, L = Osnabrueck, O = MyCompany GmbH, OU = Geschaeftsfuehrung, CN = MyCompany primary CA (untrusted)
depth=2: C = DE, ST = Niedersachsen, L = Osnabrueck, O = MyCompany GmbH, OU = Geschaeftsfuehrung, CN = MyCompany root CA
I also created a chain.pem file by concatinate all certs into it in the same order as listed above.
Now, I give the chain.pem to my Webserver as cert-file. I also added the root_cert.pem to my Operating System as trusted with this command.
PS> Import-Certificate -FilePath ./root_cert.pem -CertStoreLocation Cert:\LocalMachine\Root
Now opening the browser I got errors
- Chrome says NET::ERR_CERT_COMMON_NAME_INVALID
- FireFox says SEC_ERROR_UNKNOWN_ISSUER
If I click on show certificate, both browsers list the certificates above.
Unfortunately the browsers dont tell me the exact issues they have or give a hint how to solve them.
May I ask for help regarding my specific problem and also for a nice reference for what exactly is required to make a browser trust a server certificate created with a chain by yourself, so other people who encounter similar problems may find help? Thanks!
Remark: I only want to add the root_cert.pem as trusted to the operating system, and not any intermediate certificate.
CodePudding user response:
In 2017 there was a change in how browsers check certificates for validity. Instead of using the common name (cn), they now use the subjectAltName. see also: heise
The subjectAltName is a extenstion to a certificate and needs to be added to it, continaing the DNS or IP of the host.
Hence it is an extension, it is not part of the subject standard of openssl. See here how to set the subjectAltName for openssl.
On top of that openssl has a known bug, that will prevent the transfer of the subjectAltName-extension on signing a request. You need to set it manually via a config file. CLI also not supported here. Find the solution here
FireFox send the mentioned error because it do not link to the operating system for Root-CA, you need to add it separately to FireFox.
Finally, if you encounter any problems of validity of your created certificate:
- Use FireFox to check your https conncection, hence FireFox provide more detailed Error messages thon other browsers.
- dont forget to add your Root-CA to its dedicated cert-store.
- Check Security & Signing Algorithms. They have to be up to date for all certificates!
- Check for a correct subjectAltName to be present and valid (exactly the same value as in the reqeust URL).
- Make sure your webserver sends not only its certificate, but the whole chain. Else there will be unknown issuer error, if you use a intermediate CA. See here