Re: x509 Extension missing constructors

David Hook <dgh-rTAZ0PM/[email protected]> Fri, 12 Jul 2019 10:18:27 +1000
Newsgroups gmane.comp.encryption.bouncy-castle.devel
Message-ID <[email protected]>
I've added a static create() method. There would be a type clash with
the constructor with ASN1OctetString otherwise.

Regards,

David

On 11/7/19 7:55 pm, cryptearth wrote:
> 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
>
>