x509 Extension missing constructors

cryptearth <[email protected]> Thu, 11 Jul 2019 11:55:31 +0200
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <[email protected]>
Hi there, Matt here.

As I'm building a helper class for set up and use my own PKI CA I 
noticed that the class org.bouncycastle.asn1.x509.Extension is missing 
constructors:

Extension(ASN1ObjectIdentifier, ASN1Boolean, ASN1Encodable)
Extension(ASN1ObjectIdentifier, boolean, ASN1Encodable)

Why I think one or both of this constructors missing: 
org.bouncycastle.cert.X509v3CertificateBuilder has the method 
addExtension(ASN1ObjectIdentifier, boolean, ASN1Encodable) so it's easy 
to do some like this:

.addExtension(Extension.basicConstraints, true, new BasicConstraints(true))

For a helper it's better to have an array of type Extension to rapid add 
them in a loop with the method addExtension(Extension). The major 
inconvenience here is that to set up the array one has to write a line 
like this:

new Extension(Extension.basicConstraints, true, (new 
BasicConstraints(true)).getEncoded())

This involves error prone double conversion from object to byte array 
and back to an object just because there is now constructor taking an 
ASN1Encodable directly. As side note: Aside from possible error prone it 
looks like code smell and interrupts the code flow when reading it 
without knowing the lib or figure it out with doc.

Thanks in advance and maybe consider adding one or both constructors in 
next release.

Matt