[英]PKI question. Key validity
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. 我要准备一个文件:一个.der文件和一个.p12文件,以及一个密钥对,我们应该使用它们在Java代码中创建和验证数字签名。
I must save both keys in a MySql-Database-Table -> Keys(id, publicKey, privateKey, validity) 我必须将两个密钥都保存在MySql-Database-Table中->密钥(id,publicKey,privateKey,有效性)
To read both keys is not a big problem now, but I have no idea, how to read information about their validity in Java. 读取两个密钥现在不是什么大问题,但是我不知道如何在Java中读取有关其有效性的信息。 Is it possible? 可能吗?
Can anybody give an example for that? 有人可以举一个例子吗?
Tnanks, 坦克
Mur 慕尔
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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.