Golang crypto/x509/pkix.AttributeTypeAndValue type example
package crypto/x509/pkix
AlgorithmIdentifier represents the ASN.1 structure of the same name. See RFC 5280, section 4.1.1.2.
Golang crypto/x509/pkix.AttributeTypeAndValue type usage example
import "encoding/asn1"
...
var publicKeyBytes []byte
var (
oidRsa = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1}
oidEcdsa = asn1.ObjectIdentifier{1, 2, 840, 10045, 2, 1}
)
....
cert, err = asn1.Marshal(certificate{
Validity: validity{
NotBefore: time.Now(),
NotAfter: time.Date(2049, 12, 31, 23, 59, 59, 0, time.UTC),
},
Subject: []pkix.AttributeTypeAndValue{{
Type: asn1.ObjectIdentifier{1, 2, 3, 4},
Value: "example",
}},
SubjectPublicKeyInfo: subjectPublicKeyInfo{
// see http://golang.org/pkg/crypto/x509/pkix/#AlgorithmIdentifier
AlgorithmIdentifier: pkix.AlgorithmIdentifier{
Algorithm: oidRsa,
Parameters: asn1.RawValue{
Tag: 5,
},
},
Bytes: asn1.BitString{
Bytes: publicKeyBytes,
BitLength: 8 * len(publicKeyBytes),
},
},
})
Reference :
https://www.socketloop.com/references/golang-crypto-x509-pkix-algorithmidentifier-type-example
http://golang.org/pkg/crypto/x509/pkix/#AttributeTypeAndValue
Advertisement
Something interesting
Tutorials
+14k Golang : concatenate(combine) strings
+6.1k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example
+10.6k Android Studio : Simple input textbox and intercept key example
+8.3k Golang : Number guessing game with user input verification example
+11.5k Golang : Generate DSA private, public key and PEM files example
+9.4k Golang : Terminate-stay-resident or daemonize your program?
+7.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+7.3k Golang : Calculate how many weeks left to go in a given year
+5.4k Golang : fmt.Println prints out empty data from struct
+26k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+6.3k Golang : Extract sub-strings