Skip to content

Commit

Permalink
Clone the DER bytes before parsing the certificate.
Browse files Browse the repository at this point in the history
Otherwise the Certificate.Raw byte array will be freed in the WinCertStore.Close() function.

PiperOrigin-RevId: 558013229
  • Loading branch information
CertoToStore Team authored and copybara-github committed Aug 18, 2023
1 parent ce5ed45 commit c4d4bf9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion certtostore_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func certContextToX509(ctx *windows.CertContext) (*x509.Certificate, error) {
slice.Data = uintptr(unsafe.Pointer(ctx.EncodedCert))
slice.Len = int(ctx.Length)
slice.Cap = int(ctx.Length)
return x509.ParseCertificate(der)
return x509.ParseCertificate(append([]byte{}, der...))
}

// extractSimpleChain extracts the requested certificate chain from a CertSimpleChain.
Expand Down

0 comments on commit c4d4bf9

Please sign in to comment.