Skip to content

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

@perj

Description

@perj

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions