实现 org.jscep.server.ScepServlet 我需要为方法 doEnroll( List<X509Certificate> doEnroll(CertificationRequest certificationRequest)
) 提供一个实现。
如何从提供的 CertificationRequest 中返回 X509Certificate?
除了 CertificationRequest 我还有我需要用于签名的证书
从认证请求中获取公钥就足够了,因为我拥有用于生成证书的其余代码。
到目前为止我所拥有的:
protected List<X509Certificate> doEnroll(CertificationRequest certificationRequest) throws OperationFailureException, Exception {
CaCertificate caCertificate = getSelfSignedCertificate();
X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
certGen.setSerialNumber(BigInteger.valueOf(System.currentTimeMillis()));
certGen.setIssuerDN(caCertificate.getCertificate().getSubjectX500Principal());
certGen.setNotBefore(notBefore);
certGen.setNotAfter(notAfter);
certGen.setSubjectDN(certificationRequest.getCertificationRequestInfo().getSubject());
certGen.setPublicKey(publicKey); // this is basically what I need
X509Certificate issuedCert = certGen.generate(caCertificate.getKeypair().getPrivate());
List<X509Certificate> x509Certificates = new ArrayList<X509Certificate>();
x509Certificates.add(issuedCert);
return x509Certificates;
}