0

How could I check the validity of a PFX certificate programmatically using java?

I found various ways to do this (like using openssl), but none using Java.

Denis
  • 3,954
  • 4
  • 29
  • 60

1 Answers1

0

You can acheive this using boucycastle libraries. Check below github project for the same which read the p12 file and get the certificate details.

https://github.com/rosmahajan/java-read-p12

It is simple java class loading the p12/pfx file and read the certificate details. Once you get the x509Certificate object try below command to check the validity of certificate

x509.checkValidity();

Sometime renaming pfx file to p12 works as both are PKCS#12 file but if renaming doesn't work , try below to convert pfx to p12 using keytool

keytool -importkeystore -destkeystore new.p12 -deststoretype pkcs12 -srckeystore original.pfx

For more information: convert pfx format to p12

Ros5292
  • 1,211
  • 1
  • 13
  • 20