public Certificate generateCert(CertificationRequest csr) throws Exception { if (!verifyPopo(csr)) { throw new Exception("CSR invalid"); } CertificationRequestInfo reqInfo = csr.getCertificationRequestInfo(); return generateCert(reqInfo.getSubjectPublicKeyInfo(), reqInfo.getSubject()); }
public static X509Certificate generateSelfsignedCert(CertificationRequest csr, PrivateKey identityKey) throws CertificateException { requireNonNull("csr", csr); return generateSelfsignedCert(csr.getCertificationRequestInfo().getSubject(), csr.getCertificationRequestInfo().getSubjectPublicKeyInfo(), identityKey); }
public static CertificateRequest loadCertificateRequest(Reader reader) throws IOException { try (PEMReader pr = new PEMReader(reader)) { CertificationRequest req = (CertificationRequest) pr.readObject(); // get the CN String cn = (String) ((X509Name) req.getCertificationRequestInfo().getSubject()).getValues(new DERObjectIdentifier("2.5.4.3")).get(0); // build the key KeyFactory kf = KeyFactory.getInstance("RSA"); PublicKey key = kf.generatePublic(new RSAPublicKeySpec( ((ASN1Integer)((DERSequence) req.getCertificationRequestInfo().getSubjectPublicKeyInfo().getPublicKey()).getObjectAt(0)).getValue(), ((ASN1Integer)((DERSequence) req.getCertificationRequestInfo().getSubjectPublicKeyInfo().getPublicKey()).getObjectAt(1)).getValue() )); return new CertificateRequest(cn, key); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { throw new IOException("Failed to parse certificate request", e); } }
InvalidKeyException SubjectPublicKeyInfo subjectPKInfo = reqInfo.getSubjectPublicKeyInfo();
public EnrolmentResponse scepCertPoll(PrivateKey identityKey, X509Certificate identityCert, CertificationRequest csr, X500Name issuer) throws ScepClientException { ScepUtil.requireNonNull("csr", csr); TransactionId tid; try { tid = TransactionId.sha1TransactionId( csr.getCertificationRequestInfo().getSubjectPublicKeyInfo()); } catch (InvalidKeySpecException ex) { throw new ScepClientException(ex.getMessage(), ex); } return scepCertPoll(identityKey, identityCert, tid, issuer, csr.getCertificationRequestInfo().getSubject()); }
private EnrolmentResponse enroll(MessageType messageType, CertificationRequest csr, PrivateKey identityKey, X509Certificate identityCert) throws ScepClientException { TransactionId tid; try { tid = TransactionId.sha1TransactionId( csr.getCertificationRequestInfo().getSubjectPublicKeyInfo()); } catch (InvalidKeySpecException ex) { throw new ScepClientException(ex.getMessage(), ex); } PkiMessage pkiMessage = new PkiMessage(tid, messageType); pkiMessage.setMessageData(csr); ContentInfo envRequest = encryptThenSign(pkiMessage, identityKey, identityCert); ScepHttpResponse httpResp = httpSend(Operation.PKIOperation, envRequest); CMSSignedData cmsSignedData = parsePkiMessage(httpResp.getContentBytes()); DecodedPkiMessage response = decode(cmsSignedData, identityKey, identityCert); assertSameNonce(pkiMessage, response); return new EnrolmentResponse(response); }
SubjectPublicKeyInfo publicKeyInfo = certTemp.getSubjectPublicKeyInfo();
SubjectPublicKeyInfo publicKeyInfo = certTemp.getSubjectPublicKeyInfo();
SubjectPublicKeyInfo publicKeyInfo = certTemp.getSubjectPublicKeyInfo();
csrReqInfo.getSubjectPublicKeyInfo(), (Date) null, (Date) null, extensions, certprofileName); CertificateInfo cert = ca.generateCert(certTemplateData, requestor,