Creating an indefinitely-valid self-signed x509 certificate

Felipe Gasper felipe at
Tue Dec 27 02:09:39 UTC 2022

If all else fails, this should be possible in Perl with Crypt::Perl.


> On Dec 26, 2022, at 20:46, Jeremy Saklad via openssl-users <openssl-users at> wrote:
> Hash: SHA512
> I find myself regularly creating self-signed certificates that are verified out-of-band, through DANE, pinning the file, or other means. Since the out-of-band verification determines validity, there is no reason to set an expiration date on the certificate itself.
> Section of RFC 5280 states that an x509 certificate without a well-defined expiration date SHOULD have a notAfter value of 99991231235959Z. However, I see no practical way to achieve this using the openssl command-line options. In fact, I see no way to set an explicit expiration date at all. Am I missing something?
> The following is the sort of command I am using (with OpenSSL 3.0.7) to produce self-signed certificates. How could I set an absolute time like the RFC recommends?
> openssl req -x509 -key host.example.key -addext keyUsage=digitalSignature -addext extendedKeyUsage=serverAuth -subj "/CN=host.example/" -out ~/host.example.crt
> b3BlbnBncGtleS5zYWtsYWQ1LmNvbS9maW5nZXJwcmludC9GRERGQzRBNEE2N0Qw
> 9oe111vtIPI8AxWOc0xfIuWA8TMKrhzJEaeGYwD/c0qemFs1Ou5s4nB/gdhBIfWm
> vFNQa2Pz3zhm3JVwyQk=
> =fEvX

More information about the openssl-users mailing list