Golang crypto/x509/pkix.CertificateList type and HasExpired() function example

package crypto/x509/pkix

CertificateList represents the ASN.1 structure of the same name. See RFC 5280, section 5.1. Use Certificate.CheckCRLSignature to verify the signature.

Golang crypto/x509/pkix.CertificateList type and HasExpired() function usage example

 certList, err := x509.ParseDERCRL([]byte(crlBytes))

 if err != nil {
 fmt.Println(err)
 os.Exit(1)
 }

 fmt.Printf("TBSCertList : %v\n\n", certList.TBSCertList)
 fmt.Printf("SignatureAlgorithm : %v\n\n", certList.SignatureAlgorithm)
 fmt.Printf("SignatureValue : %v\n\n", certList.SignatureValue)

and

 if certList.HasExpired(time.Unix(1302517272, 0)) {
 fmt.Println("CRL has expired!")
 }

Reference :

https://www.socketloop.com/references/golang-crypto-x509-parsedercrl-function-example

http://golang.org/pkg/crypto/x509/pkix/#CertificateList

Advertisement