Skip to content

crypto does not recognize the extension "authority key identifier" #43868

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

Closed
GOODPWDCETCSZ opened this issue Jan 23, 2021 · 2 comments
Closed

Comments

@GOODPWDCETCSZ
Copy link

GOODPWDCETCSZ commented Jan 23, 2021

What version of Go are you using (go version)?

$ go version
1.13, 1.15

Does this issue reproduce with the latest release?

Yes (1.15)

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

Ubuntu, amd64

What did you do?

  1. Install ZCertificate (https://github.com/zmap/zcertificate)
  2. ./zcertificate seed-77s38-921c17.pem

What did you expect to see?

To show users duplicate extensions (authority key identifier) or report duplicate extension error according to RFC 5280.

What did you see instead?

"extensions":{"key_usage":{"certificate_sign":true,"value":32},"basic_constraints":{"is_ca":false},"subject_key_id":"bc93a7c14d51a1b11e5dc9c191eadb5b53d5bc58"},"unknown_extensions":[{"id":"2.16.840.1.113730.1.13","critical":true,"value":"Fh1oZXJlIGlzIHRoZSBuc0NvbW1lbnQgY29udGVudA=="}]

seed-77s38-921c17.zip

@seankhliao
Copy link
Member

This appears to be an issue with zcertificate and not Go, both instances of 2.5.29.35 (authorityKeyIdentifier) are returned

package main

import (
	"crypto/x509"
	"encoding/base64"
	"encoding/pem"
	"fmt"
	"log"
	"os"
)

func main() {
	b, err := os.ReadFile("x.pem")
	if err != nil {
		log.Fatal(err)
	}
	block, _ := pem.Decode(b)
	c, err := x509.ParseCertificate(block.Bytes)
	if err != nil {
		log.Fatal(err)
	}
	for _, e := range c.Extensions {
		fmt.Println(e.Id.String(), base64.StdEncoding.EncodeToString(e.Value))
	}
}

output:

» go run .
2.16.840.1.113730.1.13
---
2.5.29.35 MBaAFOrTnfL6EhUda5ABHx3bJ3+v0WXX
2.5.29.14 BBS8k6fBTVGhsR5dycGR6ttbU9W8WA==
2.5.29.15 AwICBA==
2.5.29.19 MAA=
2.16.840.1.113730.1.13 Fh1oZXJlIGlzIHRoZSBuc0NvbW1lbnQgY29udGVudA==
2.5.29.35 ME+hSqRIMEYxCzAJBgNVBAYTAlVOMQwwCgYDVQQIDANOWVMxDTALBgNVBAoMBFVOR0ExDTALBgNVBAsMBFVOU0MxCzAJBgNVBAMMAkRUggEB

@GOODPWDCETCSZ
Copy link
Author

Thanks.

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

No branches or pull requests

3 participants