Skip to content

Commit

Permalink
Free certificate handles while looking for one to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
hslatman committed Apr 15, 2024
1 parent 634d6c1 commit 75696c3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions kms/capi/capi.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,10 @@ func (k *CAPIKMS) DeleteCertificate(req *apiv1.DeleteCertificateRequest) error {
if err != nil {
return fmt.Errorf("findCertificateInStore failed: %w", err)
}

if certHandle == nil {
return nil
}
defer windows.CertFreeCertificateContext(certHandle)

x509Cert, err := certContextToX509(certHandle)
if err != nil {
Expand All @@ -874,7 +874,6 @@ func (k *CAPIKMS) DeleteCertificate(req *apiv1.DeleteCertificateRequest) error {
return fmt.Errorf("failed removing certificate: %w", err)
}

windows.CertFreeCertificateContext(certHandle)
return nil
}
prevCert = certHandle
Expand Down

0 comments on commit 75696c3

Please sign in to comment.