Skip to content

The asn1 Marshal/Unmarshal get confused if I use a type instead the original type #15826

Closed
@ggeorgiev

Description

@ggeorgiev

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    1.6
  2. What operating system and processor architecture are you using (go env)?
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH="/Users/.../golang"
    GORACE=""
    GOROOT="/usr/local/go"
    GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
    GO15VENDOREXPERIMENT="1"
    CC="/usr/local/bin/gcc-5"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fno-common"
    CXX="/usr/local/bin/c++-5"
    CGO_ENABLED="1"
  3. What did you do?
    If I have
    id_sha1 = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26}
    type Foo struct {
    oid asn1.ObjectIdentifier
    }
    this works correctly, but if I change it to:

type AlgorithmId asn1.ObjectIdentifier
id_sha1 = AlgorithmId{1, 3, 14, 3, 2, 26}
type Foo struct {
oid AlgorithmId
}

which seems to be the way most of the asn1 documentations are written the asn1 marshaling gets confused.

  1. What did you expect to see?
    I would expect the marshaller to be smart enough to recognize that a type is originating from the asn1.ObjectIdentifier and serialize it as such
  2. What did you see instead?
    The asn1.ObjectIdentifier is serialized as a binary blob

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