-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x509: make Windows policy parameter type version-specific #286
Conversation
Go 1.11 needs syscall.CertChainPolicyPara.ExtraPolicyPara to have type syscall.Pointer, but in previous versions of Go this had type uintptr. As we have a fork of crypto/x509, our source code for x509 can be a different version than the current compiler. To allow our code to work with both 1.11 and earlier versions, encapsulate the cast into a version-specific function. Fixes google#284
Codecov Report
@@ Coverage Diff @@
## master #286 +/- ##
=======================================
Coverage 69.98% 69.98%
=======================================
Files 68 68
Lines 8769 8769
=======================================
Hits 6137 6137
Misses 2086 2086
Partials 546 546 Continue to review full report at Codecov.
|
// syscall.CertChainPolicyPara is of type syscall.Pointer. See: | ||
// https://github.com/golang/go/commit/4869ec00e87ef | ||
|
||
func convertToPolicyParaType(p unsafe.Pointer) syscall.Pointer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can do something like this, hiding all the complexity inside this function here:
func getCertChainPolicyPara(p *syscall.SSLExtraCertChainPolicyPara) *syscall.CertChainPolicyPara {
return &syscall.CertChainPolicyPara{
ExtraPolicyPara: (syscall.Pointer)(unsafe.Pointer(p))
}
and simplify the main code:
para := getCertChainPolicyPara(sslPara)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifying the main code isn't necessarily something we want -- we (mostly) try to minimize deltas from the upstream codebase so that it's easier to merge in new versions.
// syscall.CertChainPolicyPara was of type uintptr. See: | ||
// https://github.com/golang/go/commit/4869ec00e87ef | ||
|
||
func convertToPolicyParaType(p unsafe.Pointer) uintptr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar code here:
func getCertChainPolicyPara(p *syscall.SSLExtraCertChainPolicyPara) *syscall.CertChainPolicyPara {
return &syscall.CertChainPolicyPara{
ExtraPolicyPara: (uintptr)(unsafe.Pointer(p))
}
Go 1.11 needs syscall.CertChainPolicyPara.ExtraPolicyPara to
have type syscall.Pointer, but in previous versions of Go this
had type uintptr.
As we have a fork of crypto/x509, our source code for x509 can be
a different version than the current compiler.
To allow our code to work with both 1.11 and earlier versions,
encapsulate the cast into a version-specific function.
Fixes #284