in pkg/internal/crypto/crypto_windows.go [86:110]
func GetAUsableCert(handle syscall.Handle) (cert *syscall.CertContext, _ error) {
var testCert *CertContext
var prevCert *CertContext
procCertEnumCertificatesInStore := Modcrypt32.NewProc("CertEnumCertificatesInStore")
for {
ret, _, _ := syscall.Syscall(
procCertEnumCertificatesInStore.Addr(),
2,
uintptr(handle),
uintptr(unsafe.Pointer(prevCert)),
0)
// Not that we don't handle ENotFound, since that's an error case for us (we couldn't find a cert)
testCert = (*CertContext)(unsafe.Pointer(ret))
usable := isAUsableCert(testCert)
if usable {
// We need a syscall.CertContext
syscallContext := (*syscall.CertContext)(unsafe.Pointer(ret))
return syscallContext, nil
}
prevCert = testCert
}
}