signatureObj.update(tobesigned);
byte[] signature = signatureObj.sign();
// Compose tbsCert, algId and signature into a DER sequence.
// This will be the certificate in DER encoded form
DEREncodableVector certDerVec = new DEREncodableVector();
certDerVec.add(tbsCert);
certDerVec.add(algId);
certDerVec.add(new DERBitString(signature));
DERSequence certDerSeq = new DERSequence(certDerVec);
byte[] certData = certDerSeq.getEncoded();
// Create a java.security.cert.Certificate object
Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(certData));