Skip to content

crypto/x509: support Inhibit Any-policy and Policy Constraints #68484

Description

@satsrini

Important

The current proposal is #68484 (comment).

Go version

go version go1.20.4 windows/amd64

Output of go env in your module/workspace:

GO111MODULE=
 GOARCH=amd64
 GOBIN=
 GOCACHE=C:\Users\ ****\AppData\Local\go-build
 GOENV=C:\Users\ ****\AppData\Roaming\go\env
 GOEXE=.exe
 GOEXPERIMENT=
 GOFLAGS=
 GOHOSTARCH=amd64
 GOHOSTOS=windows
 GOINSECURE=
 GOMODCACHE=C:\git\pkg\mod
 GONOPROXY=
 GONOSUMDB=
 GOOS=windows
 GOPATH=C:\git
 GOPRIVATE=
 GOPROXY=https://proxy.golang.org,direct
 GOROOT=C:\Program Files\Go
 GOSUMDB=sum.golang.org
 GOTMPDIR=
 GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
 GOVCS=
 GOVERSION=go1.20.4
 GCCGO=gccgo
 GOAMD64=v1
 AR=ar
 CC=gcc
 CXX=g++
 CGO_ENABLED=1
 GOMOD=c:\git\****\****\go.mod
 GOWORK=
 CGO_CFLAGS=-O2 -g
 CGO_CPPFLAGS=
 CGO_CXXFLAGS=-O2 -g
 CGO_FFLAGS=-O2 -g
 CGO_LDFLAGS=-O2 -g
 PKG_CONFIG=pkg-config
 GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\S****\AppData\Local\Temp\go-build1520036143=/tmp/go-build -gno-record-gcc-switches

What did you do?

To validate/verify the X509 certificates that contain the following X509 critical extensions using https://github.com/golang/go/blob/master/src/crypto/x509/verify.go#L753

               _a. X509v3 Policy Constraints: critical
                Require Explicit Policy:0, Inhibit Policy Mapping:0

               b. X509v3 Inhibit Any Policy: critical
                0_          
code snippet:

_,err = x509cert.Verify(x509.VerifyOptions{
		KeyUsages:     []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth},
		Roots:         rootCertsPool,
		Intermediates: intermediatesCertPool,
	})

What did you see happen?

It throws the error saying
"x509: unhandled critical extension"

What did you expect to see?

Certificate Verification done successfully with out any error.

Additional info:

This is because of the following code.
https://github.com/golang/go/blob/master/src/crypto/x509/parser.go#L780
https://github.com/golang/go/blob/master/src/crypto/x509/verify.go#L565

as the following Extensions OIDs are not handled in the above mentioned GO Lang code.
2.5.29.54 (Require Explicit Policy:0, Inhibit Policy Mapping:0)
2.5.29.36 (X509v3 Inhibit Any Policy: critical)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions