[BouncyCastle] PKCS10CertificationRequest.getEncoded() return 是什么编码?

What encoding does [BouncyCastle] PKCS10CertificationRequest.getEncoded() return?

它是 return DER encoded 数据,还是其他格式?

我能找到的 Javadoc 在细节方面还有待改进...

好吧,尽管有人认为可以对这个问题投反对票,但为了 post 的真实性,我会 post 在这里回答。

至少对于 v1.52,org.bouncycastle.pkcs.PKCS10CertificationRequest#getEncoded() 实现为:

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

这会调用 org.bouncycastle.asn1.pkcs.CertificationRequest#getEncoded(),这会导致继承的方法 org.bouncycastle.asn1.ASN1Object#getEncoded()。这个方法实际上有一些 Javadoc,它声明 "Return the default BER or DER encoding for this object".

我不确定这是否保证 DER 编码,所以我做了以下操作:

private byte[] makeDEREncodedRequest(final PKCS10CertificationRequest request) {
    try {
        return request.toASN1Structure().getEncoded(ASN1Encoding.DER);
    } catch (IOException e) {
        // ... <Exception handling code> ...
    }
}