Skip to content

Commit

Permalink
Merge pull request #582 from smallstep/josh/fix-extra-capi-context-free
Browse files Browse the repository at this point in the history
Remove extraneous 'CertFreeCertificateContext' in capi.
  • Loading branch information
joshdrake authored Aug 30, 2024
2 parents 1894555 + d2a8233 commit 32782fa
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions kms/capi/capi.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ func (k *CAPIKMS) DeleteCertificate(req *apiv1.DeleteCertificateRequest) error {
if certHandle == nil {
return nil
}
defer windows.CertFreeCertificateContext(certHandle)

if err := windows.CertDeleteCertificateFromStore(certHandle); err != nil {
return fmt.Errorf("failed removing certificate: %w", err)
Expand Down Expand Up @@ -822,7 +821,6 @@ func (k *CAPIKMS) DeleteCertificate(req *apiv1.DeleteCertificateRequest) error {
if certHandle == nil {
return nil
}
defer windows.CertFreeCertificateContext(certHandle)

if err := windows.CertDeleteCertificateFromStore(certHandle); err != nil {
return fmt.Errorf("failed removing certificate: %w", err)
Expand Down Expand Up @@ -862,10 +860,10 @@ func (k *CAPIKMS) DeleteCertificate(req *apiv1.DeleteCertificateRequest) error {
if certHandle == nil {
return nil
}
defer windows.CertFreeCertificateContext(certHandle)

x509Cert, err := certContextToX509(certHandle)
if err != nil {
defer windows.CertFreeCertificateContext(certHandle)
return fmt.Errorf("could not unmarshal certificate to DER: %w", err)
}

Expand Down

0 comments on commit 32782fa

Please sign in to comment.