Skip to content
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

Merged
merged 1 commit into from
Jul 5, 2018

Conversation

daviddrysdale
Copy link
Contributor

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

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
Copy link

codecov bot commented Jul 4, 2018

Codecov Report

Merging #286 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b560b3...044b82e. Read the comment docs.

// syscall.CertChainPolicyPara is of type syscall.Pointer. See:
// https://github.com/golang/go/commit/4869ec00e87ef

func convertToPolicyParaType(p unsafe.Pointer) syscall.Pointer {

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)

Copy link
Contributor Author

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 {

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))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants