Skip to content

Commit 32782fa

Browse files
authored
Merge pull request #582 from smallstep/josh/fix-extra-capi-context-free
Remove extraneous 'CertFreeCertificateContext' in capi.
2 parents 1894555 + d2a8233 commit 32782fa

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

kms/capi/capi.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ func (k *CAPIKMS) DeleteCertificate(req *apiv1.DeleteCertificateRequest) error {
791791
if certHandle == nil {
792792
return nil
793793
}
794-
defer windows.CertFreeCertificateContext(certHandle)
795794

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

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

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

0 commit comments

Comments
 (0)