crmfReq.setUsername(submessage.getUsername());
crmfReq.setPassword(submessage.getPassword());
// Request and extract certificate from response
IResponseMessage response = signSession.createCertificate(admin, crmfReq, org.ejbca.core.protocol.cmp.CmpResponseMessage.class, null);
ASN1InputStream ais = new ASN1InputStream(new ByteArrayInputStream(response.getResponseMessage()));
CertRepMessage certRepMessage = PKIMessage.getInstance(ais.readObject()).getBody().getCp();
InputStream inStream = new ByteArrayInputStream(certRepMessage.getResponse(0).getCertifiedKeyPair().getCertOrEncCert().getCertificate().getEncoded());
cert = CertificateFactory.getInstance("X.509").generateCertificate(inStream);
inStream.close();
// Convert to the right response type
if (submessage.getResponseType() == CertificateRequestRequest.RESPONSE_TYPE_CERTIFICATE) {
result = cert.getEncoded();