On Wednesday, October 31, 2018 at 10:46:41 PM UTC+1, golan...@geek1.de 
wrote:
>
> Hy Natxo, 
>
> check out the pkix [0] and asn1 [1] packages. You can try to parse the 
> DER encoded subject into RDNSequence. 
>
> [0]: https://golang.org/pkg/crypto/x509/pkix/#RDNSequence 
> [1]: https://golang.org/pkg/encoding/asn1/#Unmarshal 
>
> Spoiler: 
>
> This should work: 
>
> package main 
>
> import "fmt" 
> import "crypto/x509" 
> import "encoding/asn1" 
> import "crypto/x509/pkix" 
>
> func main() { 
>   store, err := x509.SystemCertPool() 
>   if err != nil { 
>     panic(err) 
>   } 
>   subjects := store.Subjects() 
>   for _, rawSubject := range subjects { 
>     var subject pkix.RDNSequence 
>     if _, err := asn1.Unmarshal(rawSubject, &subject); err != nil { 
>       panic(err) 
>     } 
>     fmt.Printf("%+v\n", subject) 
>   } 
> } 
>
> The unmarshal code is borrowed from https://stackoverflow.com/a/50640119 
>
> Cheers, 
> Michael 
>
>  
Hi,

it works beautifully. Thanks a lot.

-- 
regards,
Natxo

-- 
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.

Reply via email to