0

Does it return DER encoded data, or some other format?

The Javadoc I've been able to find leaves something to be desired details-wise...

1 Answer 1

3

At least for v1.52, org.bouncycastle.pkcs.PKCS10CertificationRequest#getEncoded() is implemented as:

public byte[] More ...getEncoded()
    throws IOException
{
    return certificationRequest.getEncoded();
}

This calls org.bouncycastle.asn1.pkcs.CertificationRequest#getEncoded(), which results in the inherited method org.bouncycastle.asn1.ASN1Object#getEncoded(). This method actually has some Javadoc, and it states "Return the default BER or DER encoding for this object".

I wasn't completely sure whether this guarantees DER encoding, so I did the following:

private byte[] makeDEREncodedRequest(final PKCS10CertificationRequest request) {
    try {
        return request.toASN1Structure().getEncoded(ASN1Encoding.DER);
    } catch (IOException e) {
        // ... <Exception handling code> ...
    }
}
1
  • I presume it did return DER? You don't say in the answer. I guess the reason that somebody downvoted is that you can expect a PKCS#10 defined certificate request to be returned when getEncoded() is called. That's what the class is there for. You only need to look at the PKCS#10 standard to see what's in it. Jun 13, 2015 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.