tags:

views:

21

answers:

1

I've got to files: a .der- and a .p12-file, with a key pair, which we should use for creating und verifiing digital signatures in our java code.

I must save both keys in a MySql-Database-Table -> Keys(id, publicKey, privateKey, validity)

To read both keys is not a big problem now, but I have no idea, how to read information about their validity in Java. Is it possible?

Can anybody give an example for that?

Tnanks,

Mur

+1  A: 

After I searched for an answer again, I found it. And here is a solution:

InputStream inStream = new FileInputStream("YOUR_FILE.der");

CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert_x509 = (X509Certificate) cf.generateCertificate(inStream2);
Date validFrom = cert_x509.getNotBefore();
Date validTo = cert_x509.getNotAfter();

inStream.close();
Mur Votema