I am trying to create a DER file using encoding/asn1, and I keep getting an invalid Object Identifier runtime error. asn1.ObjectIdentifier
is just an []int, so I'm not sure what's invalid.
package main
import (
"encoding/asn1"
"fmt"
"log"
)
type algorithm struct {
Algo asn1.ObjectIdentifier
Null asn1.RawValue
}
func main() {
var myCert algorithm
myCert.Algo = asn1.ObjectIdentifier{42, 134, 72, 134}
myCert.Null = asn1.NullRawValue
mdata, err := asn1.Marshal(myCert)
if err != nil {
log.Fatalln(err)
}
fmt.Println(mdata)
}
The program exits with the following error: "asn1: structure error: invalid object identifier"
Playground example here