Golang crypto/x509/pkix.TBSCertificateList example

package crypto/x509/pkix

TBSCertificateList represents the ASN.1 structure of the same name. See RFC 5280, section 5.1.

Golang crypto/x509/pkix.TBSCertificateList usage example

 cert, _ := x509.ParseCertificate(block.Bytes)
 now := time.Unix(1000, 0)
 expiry := time.Unix(10000, 0)

 revokedCerts := []pkix.RevokedCertificate{
 {
 SerialNumber: big.NewInt(1),
 RevocationTime: now,
  },
  {
 SerialNumber: big.NewInt(42),
 RevocationTime: now,
 },
 }

 tbsCertList := pkix.TBSCertificateList{
 Version: 2,
 Signature: pkix.AlgorithmIdentifier{
 Algorithm: oidSignatureSHA1WithRSA,
  },
  Issuer: cert.Subject.ToRDNSequence(),
  ThisUpdate: now.UTC(),
  NextUpdate: expiry.UTC(),
  RevokedCertificates: revokedCerts,
 }

Reference :

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

Advertisement