如何使用Java API签署X509证书请求? [英] How to sign X509 certificate requests by using java API?
问题描述
我的Java程序应使用自己的密钥对收到的X509证书请求进行签名。
证书申请采用PEM格式。用于签名的密钥/证书在本地Java密钥存储区中。
My java program should sign received X509 certificate requests by using own key. Certificate requests are in PEM format. The key/certificate for signing is in the local java key store.
我从 java.security
包装。但是没有成功。
I have seek suitable classes from java.security
package. But without success.
应该使用哪些Java API类来签名X509证书?
What classes of Java API should be used for signing X509 certificates?
我可以转换PEM到DER,但是DER的解码会引起问题。
我尝试了以下操作:
I can convert PEM to DER, but decoding of DER causes problems. I have tried the following:
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(derReq));
CertificateFactory certFact = CertificateFactory.getInstance("X.509");
java.security.cert.Certificate cert = certFact.generateCertificate(bis);
和
javax.security.cert.X509Certificate cer = X509Certificate.getInstance(derReq);
两者都会导致以下异常:
Both will cause the following exception:
javax.security.cert.CertificateException: Could not parse certificate: java.io.IOException: Empty input
因此,这些似乎仅用于签名证书,而不是X509证书请求。
So, seems that those are only for signed certificates, and not for X509 certificate requests.
推荐答案
我还没有使用Java完成任何 PKI ,但是当然通常保持不变。查看此链接: PKI Java
I haven't done any PKI with Java, but of course it usually remains the same. Check out this link: PKI Java
它涵盖了 JCE 和 BC 的必要性。
这篇关于如何使用Java API签署X509证书请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!