Skip to content

Commit f858dbd

Browse files
alexbrainmanFiloSottile
authored andcommitted
[release-branch.go1.10] crypto/tls: copy and use adjusted syscall.CertChainPolicyPara
As discussed in issue #21376, it is unsafe to have syscall.CertChainPolicyPara.ExtraPolicyPara uintptr - it has to be a pointer type. So copy syscall.CertChainPolicyPara into crypto/tls package, make ExtraPolicyPara unsafe.Pointer, and use new struct instead of syscall.CertChainPolicyPara. Fixes #25033 Change-Id: If914af056cbbb0c4d93ffaa915b3d2cb5ecad0cd Reviewed-on: https://go-review.googlesource.com/111715 Reviewed-by: Austin Clements <[email protected]> Run-TryBot: Austin Clements <[email protected]>
1 parent 71bdbf4 commit f858dbd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/crypto/x509/root_windows.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ func checkChainTrustStatus(c *Certificate, chainCtx *syscall.CertChainContext) e
9595
return nil
9696
}
9797

98+
type _CertChainPolicyPara struct {
99+
Size uint32
100+
Flags uint32
101+
ExtraPolicyPara unsafe.Pointer
102+
}
103+
98104
// checkChainSSLServerPolicy checks that the certificate chain in chainCtx is valid for
99105
// use as a certificate chain for a SSL/TLS server.
100106
func checkChainSSLServerPolicy(c *Certificate, chainCtx *syscall.CertChainContext, opts *VerifyOptions) error {
@@ -108,13 +114,13 @@ func checkChainSSLServerPolicy(c *Certificate, chainCtx *syscall.CertChainContex
108114
}
109115
sslPara.Size = uint32(unsafe.Sizeof(*sslPara))
110116

111-
para := &syscall.CertChainPolicyPara{
112-
ExtraPolicyPara: uintptr(unsafe.Pointer(sslPara)),
117+
para := &_CertChainPolicyPara{
118+
ExtraPolicyPara: unsafe.Pointer(sslPara),
113119
}
114120
para.Size = uint32(unsafe.Sizeof(*para))
115121

116122
status := syscall.CertChainPolicyStatus{}
117-
err = syscall.CertVerifyCertificateChainPolicy(syscall.CERT_CHAIN_POLICY_SSL, chainCtx, para, &status)
123+
err = syscall.CertVerifyCertificateChainPolicy(syscall.CERT_CHAIN_POLICY_SSL, chainCtx, (*syscall.CertChainPolicyPara)(unsafe.Pointer(para)), &status)
118124
if err != nil {
119125
return err
120126
}

0 commit comments

Comments
 (0)