Standard library / crypto/x509/pkix
crypto/x509/pkix.Extension
ASN.1 extension with Id OID, Critical flag and DER-encoded Value. Critical unknown extensions must be handled or rejected. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type Extension struct { Id asn1.ObjectIdentifier Critical bool `asn1:"optional"` Value []byte}Working Example
Example Snippetgo
package main
import ( "crypto/x509/pkix" "encoding/asn1" "fmt")
func main() { v := pkix.Extension{Id: asn1.ObjectIdentifier{1, 2, 3}, Critical: true, Value: []byte{5, 0}} fmt.Println(v.Critical)}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}