In 2004, I set up a small certification authority using OpenSSL on Linux and the simple management scripts provided with OpenVPN. In accordance with the guides I found at the time, I set the validity period for the root CA certificate to 10 years. Since then, I have signed many certificates for OpenVPN tunnels, web sites and e-mail servers, all of which also have a validity period of 10 years (this may have been wrong, but I didn't know better at the time).
I have found many guides about setting up a CA, but only very little information about its management, and in particular, about what has to be done when the root CA certificate expires, which will happen some time in 2014. So I have the following questions:
- Will the certificates that have a validity period extending after the expiry of the root CA certificate become invalid as soon as the latter expires, or will they continue to be valid (because they were signed during the validity period of the CA certificate)?
- What operations are needed to renew the root CA certificate and ensure a smooth transition over its expiry?
- Can I somehow re-sign the current root CA certificate with a different validity period, and upload the newly-signed cert to clients so that client certificates remain valid?
- Or do I need to replace all client certificates with new ones signed by a new root CA certificate?
- When should the root CA certificate be renewed? Close to expiry, or a reasonable time before expiry?
- If the renewal of the root CA certificate becomes a major piece of work, what can I do better now to ensure a smoother transition at the next renewal (short of setting the validity period to 100 years, of course)?
The situation is made slightly more complicated by the fact that my only access to some of the clients is through an OpenVPN tunnel that uses a certificate signed by the current CA certificate, so if I have to replace all client certs, I will need to copy the new files to the client, restart the tunnel, cross my fingers and hope that it comes up afterwards.
Keeping the same private key on your root CA allows for all certificates to continue to validate successfully against the new root; all that's required of you is to trust the new root.
The certificate signing relationship is based on a signature from the private key; keeping the same private key (and, implicitly, the same public key) while generating a new public certificate, with a new validity period and any other new attributes changed as needed, keeps the trust relationship in place. CRLs, too, can continue over from the old cert to the new, as they are, like certificates, signed by the private key.
So, let's verify!
Make a root CA:
Generate a child certificate from it:
Sign the child cert:
All set there, normal certificate relationship. Let's verify the trust:
Ok, so, now let's say 10 years passed. Let's generate a new public certificate from the same root private key.
And.. did it work?
But.. why? They're different files, right?
Yes, but, that doesn't mean that the new public key doesn't cryptographically match the signature on the certificate. Different serial numbers, same modulus:
Let's go a little further to verify that it's working in real world certificate validation.
Fire up an Apache instance, and let's give it a go (debian file structure, adjust as needed):
We'll set these directives on a
VirtualHost
listening on 443 - remember, thenewroot.pem
root certificate didn't even exist whencert.pem
was generated and signed.Let's check out how openssl sees it:
Ok, and how about a browser using MS's crypto API? Gotta trust the root, first, then it's all good, with the new root's serial number:
And, we should still be working with the old root, too. Switch Apache's config around:
Do a full restart on Apache, a reload won't switch the certs properly.
And, with the MS crypto API browser, Apache's presenting the old root, but the new root's still in the computer's trusted root store. It'll automatically find it and validate the cert against the trusted (new) root, despite Apache presenting a different chain (the old root). After stripping the new root from trusted roots and adding the original root cert, all is well:
So, that's it! Keep the same private key when you renew, swap in the new trusted root, and it pretty much all just works. Good luck!
I've noticed that CA extensions could be missing in the renewed certificate of the original CA key. This worked more appropriately for me (it creates a
./renewedselfsignedca.conf
where v3 CA extensions are defined, andca.key
andca.crt
are assumed to be the original CA key and certificate):Basic mode to extend the valid period of root (you need the public X.509 and asociated private key):
Generate the CSR from public X.509 and private key:
Re-sign the CSR with private key:
@Bianconiglio plus
-set_serial
worked for me. My server is intranet only so I am not worrying to much what the side effects are and I now have time to work on a "proper" solution.I used the following configurable script. Just set the variables
CACRT
,CAKEY
andNEWCA
.When your root certificate expires, so do the certs you've signed with it. You will have to generate a new root cert and sign new certificates with it. If you don't want to repeat the process every few years the only real option is to extend the valid date on the root cert something like ten or twenty years: The root I generated for my own use I set out twenty years.
You can't "renew" a root cert. All you can do is generate a new one.
Generate a new root at least a year or two before your old one expires so you have time to change over without being against a time wall if something goes wrong. That way you can always temporarily switch back to the old certs until you get your teething problems with the new one resolved.
As far as the VPN tunnels go, I would set up a couple of testbed servers to experiment with so you understand precisely what you have to do before you do it with a client's machine.
We have had the same issue, and that was in our case because the Debian server was out to date, and the openSSL had this issue:
https://en.wikipedia.org/wiki/Year_2038_problem
The last version of OpenSSL available for Debian 6 brings this problem. All certificates created after 23.01.2018 produces a Vality: for 1901 year !
The solution is to update the OpenSSL. You can create again the config files (with the certificates) for the clients.
The answer https://serverfault.com/a/308100/971795 seems to suggest it's not necessary to renew the private key - only renew the public key certificate is enough. However, it is best practice to rotate the private key of root CA once in a while.
The procedure is to "replace" the old CA with a new one (not just the public key certificate, but the entire CA), by
Note that step 2, 3 ensures the smooth transition from old to new CA.
For more detail, check out https://docs.aws.amazon.com/acm-pca/latest/userguide/ca-lifecycle.html#ca-succession