Skip to content

crypto/x509: invalid certificate policies #65990

Description

@fancycode

Go version

go1.22.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/devel/go-1.22'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/user/devel/go-1.22/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD=''
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2225582694=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Test program:

package main

import (
	"crypto/x509"
	"log"
	"os"
)

func main() {
	data, err := os.ReadFile("cert.crt")
	if err != nil {
		log.Fatal(err)
	}

	crt, err := x509.ParseCertificate(data)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Certificate: %s", crt.Subject)
}

Sample certificate (uncompress with gunzip):
cert.crt.gz

Run:

go run test.go

What did you see happen?

2024/02/28 11:40:48 x509: invalid certificate policies
exit status 1

Decoding with openssl works:

openssl x509 -in cert.crt -inform der -text -noout
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            7c:6d:cd:78:18:4a:91:c6:05:9b:b7:24:55:38:d5:36
...

What did you expect to see?

2024/02/28 11:40:48 Certificate: <the-subject-of-the-certificate>

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions