Hi All,
First post on the group,

I am using  go version go1.18.4 darwin/arm64.
I am trying to create X509 certificate with following code.

var COMMON_NAME = asn1.ObjectIdentifier([]int{2, 5, 4, 3})
 serial := new(big.Int).SetUint64(1)

subjectExtraNames = append(subjectExtraNames, 
pkix.AttributeTypeAndValue{Type: COMMON_NAME, Value: "golang"})

caCertTemplate := &x509.Certificate{
SerialNumber: 1,
IsCA: true,
NotBefore: time.Now(),
Subject: pkix.Name{ExtraNames: pkixAttrTypeValue},
NotAfter: time.Now().AddDate(10, 0, 0),

KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
BasicConstraintsValid: true,
}

when I inspect the created certificate using asn1parse -in <PathToPemFile>

   31:d=4  hl=2 l=  13 cons: SEQUENCE          
   33:d=5  hl=2 l=   3 prim: OBJECT            :commonName
   38:d=5  hl=2 l=   6 prim: *PRINTABLESTRING*   :golang
the common name is *PRINTABLESTRING* and not the *UTF8STRING.*

As i understand, golang strings are utf8 default then why it is not *UTF8STRING 
?*

However, in above code when i use below to create certificate
subjectExtraNames = append(subjectExtraNames, 
pkix.AttributeTypeAndValue{Type: COMMON_NAME, Value: "é um"})
and when I inspect certificate then it shows *UTF8STRING *for* é um"*

If this is how it is then is there a way to get a string without special 
characters as *UTF8STRING *in certificate?




-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f4c04b42-143c-4427-a4dc-c589e6cbeaa5n%40googlegroups.com.

Reply via email to