Skip to content

Commit

Permalink
Fix golang 1.11 compatibility on Windows
Browse files Browse the repository at this point in the history
Go 1.11beta1 introduces an incompatible change to the type of
CertChainPolicyPara.ExtraPolicyPara field [1], which results
in the following compile error on Windows:

> x509\root_windows.go:112:3: cannot use
> uintptr(unsafe.Pointer(sslPara)) (type uintptr) as type
> syscall.Pointer in field value

The fix, maintaining backward compatibility with Go 1.10 and 1.9,
is to use type alias. Unfortunately it won't work with go < 1.9
as those earlier versions lack the type alias feature.

This should fix issue google#284.

[1] golang/go@4869ec00e87ef

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Jul 4, 2018
1 parent 3b560b3 commit f74f9e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions x509/go111_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// +build go-1.11

package x509

import (
"syscall"
)

type syscallPtr = syscall.Pointer
5 changes: 5 additions & 0 deletions x509/pre_go111_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// +build !go-1.11

package x509

type syscallPtr = uintptr
2 changes: 1 addition & 1 deletion x509/root_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func checkChainSSLServerPolicy(c *Certificate, chainCtx *syscall.CertChainContex
sslPara.Size = uint32(unsafe.Sizeof(*sslPara))

para := &syscall.CertChainPolicyPara{
ExtraPolicyPara: uintptr(unsafe.Pointer(sslPara)),
ExtraPolicyPara: (syscallPtr)(unsafe.Pointer(sslPara)),
}
para.Size = uint32(unsafe.Sizeof(*para))

Expand Down

0 comments on commit f74f9e4

Please sign in to comment.