Golang crypto/x509.InvalidReason type example

package crypto/x509

Golang crypto/x509.InvalidReason type usage example

 type CertificateInvalidError struct {
  Cert *Certificate
  Reason InvalidReason
 }

 func (e CertificateInvalidError) Error() string {
  switch e.Reason {
  case NotAuthorizedToSign:
 return "x509: certificate is not authorized to sign other certificates"
  case Expired:
 return "x509: certificate has expired or is not yet valid"
  case CANotAuthorizedForThisName:
 return "x509: a root or intermediate certificate is not authorized to sign in this domain"
  case TooManyIntermediates:
 return "x509: too many intermediates for path length constraint"
  case IncompatibleUsage:
 return "x509: certificate specifies an incompatible key usage"
  }
  return "x509: unknown error"
 }

Reference :

http://golang.org/pkg/crypto/x509/#InvalidReason

Advertisement