Hi, I would like to load the public key from a DER encoded certificate
Here is my code func ExampleParsePKIXPublicKey() { raw, err := ioutil.ReadFile("/Path/To/DER/Encoded/Certificate") if err != nil { panic("failed to read certificate" + err.Error()) } pub, err := x509.ParsePKIXPublicKey(raw) if err != nil { panic("failed to parse DER encoded public key: " + err.Error()) } switch pub := pub.(type) { case *rsa.PublicKey: fmt.Println("Pub is of type RSA:", pub) case *dsa.PublicKey: fmt.Println("Pub is of type DSA:", pub) case *ecdsa.PublicKey: fmt.Println("Pub is of type ECDSA:", pub) default: panic("unknown type fo public key") } } then I get errors like below: panic: failed to parse DER encoded public key: asn1: structure error: tags don't match (6 vs {class:2 tag:0 length:3 isCompound:true}) {optional:false explicit:false application:f alse defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} ObjectIdentifier @2 any ideas to solve this problem? thanks in advance! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.