@@ -37,7 +37,7 @@ type Name struct {
3737 L string `json:"L,omitempty" yaml:"L,omitempty"` // Locality
3838 O string `json:"O,omitempty" yaml:"O,omitempty"` // OrganisationName
3939 OU string `json:"OU,omitempty" yaml:"OU,omitempty"` // OrganisationalUnitName
40- E string `json:"E,omitempty" yaml:"E,omitempty"`
40+ E string `json:"E,omitempty" yaml:"E,omitempty"`
4141 SerialNumber string `json:"SerialNumber,omitempty" yaml:"SerialNumber,omitempty"`
4242 OID map [string ]string `json:"OID,omitempty", yaml:"OID,omitempty"`
4343}
@@ -136,14 +136,15 @@ type CAConfig struct {
136136// A CertificateRequest encapsulates the API interface to the
137137// certificate request functionality.
138138type CertificateRequest struct {
139- CN string `json:"CN" yaml:"CN"`
140- Names []Name `json:"names" yaml:"names"`
141- Hosts []string `json:"hosts" yaml:"hosts"`
142- KeyRequest * KeyRequest `json:"key,omitempty" yaml:"key,omitempty"`
143- CA * CAConfig `json:"ca,omitempty" yaml:"ca,omitempty"`
144- SerialNumber string `json:"serialnumber,omitempty" yaml:"serialnumber,omitempty"`
145- Extensions []pkix.Extension `json:"extensions,omitempty" yaml:"extensions,omitempty"`
146- CRL string `json:"crl_url,omitempty" yaml:"crl_url,omitempty"`
139+ CN string `json:"CN" yaml:"CN"`
140+ Names []Name `json:"names" yaml:"names"`
141+ Hosts []string `json:"hosts" yaml:"hosts"`
142+ KeyRequest * KeyRequest `json:"key,omitempty" yaml:"key,omitempty"`
143+ CA * CAConfig `json:"ca,omitempty" yaml:"ca,omitempty"`
144+ SerialNumber string `json:"serialnumber,omitempty" yaml:"serialnumber,omitempty"`
145+ DelegationEnabled bool `json:"delegation_enabled,omitempty" yaml:"delegation_enabled,omitempty"`
146+ Extensions []pkix.Extension `json:"extensions,omitempty" yaml:"extensions,omitempty"`
147+ CRL string `json:"crl_url,omitempty" yaml:"crl_url,omitempty"`
147148}
148149
149150// New returns a new, empty CertificateRequest with a
@@ -196,9 +197,9 @@ func (cr *CertificateRequest) Name() (pkix.Name, error) {
196197 }
197198 name .ExtraNames = append (name .ExtraNames , pkix.AttributeTypeAndValue {Type : oid , Value : v })
198199 }
199- if n .E != "" {
200- name .ExtraNames = append (name .ExtraNames , pkix.AttributeTypeAndValue {Type : asn1.ObjectIdentifier {1 , 2 , 840 , 113549 , 1 , 9 , 1 }, Value : n .E })
201- }
200+ if n .E != "" {
201+ name .ExtraNames = append (name .ExtraNames , pkix.AttributeTypeAndValue {Type : asn1.ObjectIdentifier {1 , 2 , 840 , 113549 , 1 , 9 , 1 }, Value : n .E })
202+ }
202203 }
203204 name .SerialNumber = cr .SerialNumber
204205 return name , nil
@@ -430,6 +431,10 @@ func Generate(priv crypto.Signer, req *CertificateRequest) (csr []byte, err erro
430431 }
431432 }
432433
434+ if req .DelegationEnabled {
435+ tpl .ExtraExtensions = append (tpl .Extensions , helpers .DelegationExtension )
436+ }
437+
433438 if req .Extensions != nil {
434439 err = appendExtensionsToCSR (req .Extensions , & tpl )
435440 if err != nil {
0 commit comments