From 0f0339861c44899f7622161ed4206db7fad41dfc Mon Sep 17 00:00:00 2001 From: Dominik Roos Date: Fri, 13 Sep 2024 21:40:30 +0200 Subject: [PATCH] Show value for unknown OID in DN In case the OID is not known, but the value is a printable string, show the value in the DN. Handling unknown OIDs in general is hard, as they can contain arbitrary data. However, a common case is that that the value is just a printable string, which can easily be represented in the DN. If you are interested, I would also be happy to implement a mechanism to register encoders for unknown OIDs. --- certinfo.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/certinfo.go b/certinfo.go index 8ba129b..807f6da 100644 --- a/certinfo.go +++ b/certinfo.go @@ -294,6 +294,8 @@ func printName(names []pkix.AttributeTypeAndValue, buf *bytes.Buffer) []string { values = append(values, fmt.Sprintf("DC=%s", name.Value)) case oid.Equal(oidUserID): values = append(values, fmt.Sprintf("UID=%s", name.Value)) + case func() bool { _, ok := name.Value.(string); return ok }(): + values = append(values, fmt.Sprintf("%s=%s", name.Type.String(), name.Value.(string))) default: values = append(values, fmt.Sprintf("UnknownOID=%s", name.Type.String())) }