use of org.jscep.client.EnrollmentResponse in project xipki by xipki.
the class CertPollCmd method execute0.
@Override
protected Object execute0() throws Exception {
PKCS10CertificationRequest csr = new PKCS10CertificationRequest(IoUtil.read(csrFile));
Client client = getScepClient();
TransactionId transId = TransactionId.createTransactionId(CertificationRequestUtils.getPublicKey(csr), "SHA-1");
EnrollmentResponse resp = client.poll(getIdentityCert(), getIdentityKey(), new X500Principal(csr.getSubject().getEncoded()), transId);
if (resp.isFailure()) {
throw new CmdFailure("server returned 'failure'");
}
if (resp.isPending()) {
throw new CmdFailure("server returned 'pending'");
}
X509Certificate cert = extractEeCerts(resp.getCertStore());
if (cert == null) {
throw new Exception("received no certificate");
}
saveVerbose("saved polled certificate to file", new File(outputFile), cert.getEncoded());
return null;
}
use of org.jscep.client.EnrollmentResponse in project xipki by xipki.
the class EnrollCertAction method execute0.
@Override
protected Object execute0() throws Exception {
Client client = getScepClient();
PKCS10CertificationRequest csr = new PKCS10CertificationRequest(IoUtil.read(csrFile));
EnrollmentResponse resp = requestCertificate(client, csr, getIdentityKey(), getIdentityCert());
if (resp.isFailure()) {
throw new CmdFailure("server returned 'failure'");
}
if (resp.isPending()) {
throw new CmdFailure("server returned 'pending'");
}
X509Certificate cert = extractEeCerts(resp.getCertStore());
if (cert == null) {
throw new Exception("received no certificate");
}
saveVerbose("saved enrolled certificate to file", new File(outputFile), cert.getEncoded());
return null;
}
Aggregations