I'm using https://github.com/fszlin/certes to generate an SSL PEM file and private key, but throughout the process I can't seem to see where to get the certificates expiry date (or even if it's in there). I have found the order expiry date which is 7 days from now. Does anyone know if it's a property I can extract in some method or maybe later read the PEM to get the data out from there? I know I can get it from the https url once the certificate is installed, or just simply add on 90 days onto the created date, but it would be handy to get it from the certificate itself in some form during the creation process.
Asked
Active
Viewed 1,178 times
0
-
You can use `openssl`: [How to determine SSL cert expiration date from a PEM encoded certificate](https://stackoverflow.com/questions/21297853/how-to-determine-ssl-cert-expiration-date-from-a-pem-encoded-certificate). If you are on Windows, take a look at [this](https://stackoverflow.com/questions/50625283/how-to-install-openssl-in-windows-10) also. – andrewJames Jan 24 '21 at 15:00
-
Thanks for this, I did look up openssl on windows via Nuget but seemed a bit of a long work around for my requirement. But I did find a solution! For anyone else, my solution was actually quite simple: https://github.com/fszlin/certes allows you to generate the pfx file from the PEM cert. You can then use X509Certificate2 to open the pfx and GetExpirationDateString() which satisfies the query. – Stuart Palmer Jan 26 '21 at 14:05