String sigalg = cert.getSigAlgName();
X509Name subject = new X509Name(cert.getSubjectDN().toString());
PublicKey publicKey = cert.getPublicKey();
ASN1Set attributes = null;
PKCS10CertificationRequest csr = new PKCS10CertificationRequest(sigalg,
subject, publicKey, attributes, signingKey);
if (!csr.verify()) {
throw new KeyStoreException("CSR verification failed");
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
DEROutputStream deros = new DEROutputStream(os);
deros.writeObject(csr.getDERObject());
String b64 = new String(Base64.encode(os.toByteArray()));
final String BEGIN_CERT_REQ = "-----BEGIN CERTIFICATE REQUEST-----";
final String END_CERT_REQ = "-----END CERTIFICATE REQUEST-----";
final int CERT_REQ_LINE_LENGTH = 70;