fix: do not wrap nil provisioners

pull/1688/head
Panagiotis Siatras 4 months ago
parent c2c7dc470f
commit e2a73042fb
No known key found for this signature in database

@ -968,16 +968,7 @@ func (a *Authority) startCRLGenerator() error {
func (a *Authority) incrProvisionerCounter(prov *provisioner.Interface, err *error, count func(Meter, string, bool)) {
var name string
if p := *prov; p != nil {
// TODO(@azazeal): ???
switch x := p.(type) {
case *wrappedProvisioner:
if x.Interface != nil {
name = x.GetName()
}
default:
name = x.GetName()
}
name = p.GetName()
}
count(a.meter, name, *err == nil)
@ -986,16 +977,7 @@ func (a *Authority) incrProvisionerCounter(prov *provisioner.Interface, err *err
func (a *Authority) incrWebhookCounter(prov provisioner.Interface, err error, count func(Meter, string, bool)) {
var name string
if prov != nil {
// TODO(@azazeal): ???
switch x := prov.(type) {
case *wrappedProvisioner:
if x.Interface != nil {
name = x.GetName()
}
default:
name = x.GetName()
}
name = prov.GetName()
}
count(a.meter, name, err == nil)

@ -162,7 +162,6 @@ func (a *Authority) Sign(csr *x509.CertificateRequest, signOpts provisioner.Sign
// Capture the provisioner's webhook controller
case webhookController:
// TODO(@azazeal): wrap the webhook controller with functions that mutate the meter
webhookCtl = k
default:
@ -310,8 +309,10 @@ func (a *Authority) Sign(csr *x509.CertificateRequest, signOpts provisioner.Sign
cert = append([]*x509.Certificate{resp.Certificate}, resp.CertificateChain...)
// Wrap provisioner with extra information.
prov = wrapProvisioner(prov, attData)
// Wrap provisioner with extra information, if not nil
if prov != nil {
prov = wrapProvisioner(prov, attData)
}
// Store certificate in the db.
if err = a.storeCertificate(prov, cert); err != nil {

Loading…
Cancel
Save