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

encoding/asn1: class and tag constants shouldn't be private. #9236

Closed
perj opened this issue Dec 10, 2014 · 4 comments
Closed

encoding/asn1: class and tag constants shouldn't be private. #9236

perj opened this issue Dec 10, 2014 · 4 comments
Milestone

Comments

@perj
Copy link

perj commented Dec 10, 2014

I'm trying to extract an otherName from the subjectAltName of a certificate. Currently the code looks like this

if ext.Id.Equal(subjectAltName) {
    var altName asn1.RawValue
    asn1.Unmarshal(ext.Value, &altName)
    if altName.Class == 0 && altName.Tag == 16 {
        data := altName.Bytes
        for len(data) > 0 {
              var alt asn1.RawValue
              data, _ = asn1.Unmarshal(data, &alt)
              if alt.Class == 2 {
                  switch (alt.Tag) {
                  case 0:
                      ...
                  }
              }
          }
     }
}

As you can see there's a lot of magic numbers there. Almost all of those are defined constants in asn1/common.go, but they're set to private, so I can't use them. I don't think they should be private since they're well defined ASN.1 constants.

@rsc
Copy link
Contributor

rsc commented Apr 10, 2015

@agl for a decision

@rsc rsc added this to the Go1.5Maybe milestone Apr 10, 2015
@agl agl self-assigned this Apr 12, 2015
@agl agl removed this from the Go1.5Maybe milestone Apr 30, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 3, 2015
@bradfitz
Copy link
Contributor

bradfitz commented Dec 1, 2015

Considering that asn1.RawValue already exposes them, I'm also in favor of exporting the constants.

If they were public, it might be nice to make them typed constants so they can have methods, but https://golang.org/pkg/encoding/asn1/#RawValue already uses Tag and Class as just int, so I guess typed constants are out.

@bradfitz
Copy link
Contributor

bradfitz commented Dec 1, 2015

For @agl if he wants it: https://go-review.googlesource.com/17311

@gopherbot
Copy link

CL https://golang.org/cl/17311 mentions this issue.

@golang golang locked and limited conversation to collaborators Dec 14, 2016
@rsc rsc unassigned agl Jun 23, 2022
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

6 participants