func NewCA(commonName string, signer crypto.Signer) (*x509.Certificate, error) {
	template := &x509.Certificate{}
	if err := assetTagCertificate(template); err != nil {
		return nil, errors.Annotate(err, "failed tagging new CA certificate")
	}

	template.Subject = pkix.Name{
		CommonName:   commonName,
		Organization: Organisation,
	}
	now := time.Now()
	template.NotBefore = now.Add(NotBeforeJitter)
	template.NotAfter = now.AddDate(DefaultValidityYears, 0, 0)
	template.KeyUsage = x509.KeyUsageKeyEncipherment |
		x509.KeyUsageDigitalSignature |
		x509.KeyUsageCertSign
	template.BasicConstraintsValid = true
	template.IsCA = true

	der, err := x509.CreateCertificate(rand.Reader, template, template,
		signer.Public(), signer)
	if err != nil {
		return nil, errors.Annotate(err, "failed creating CA certificate")
	}

	caCert, err := x509.ParseCertificate(der)
	if err != nil {
		return nil, errors.Trace(err)
	}

	return caCert, nil
}
// Helper method to generate a new certificate authority using the provided
// common name and signer.
Helper method to generate a new certificate authority using the provided
common name and signer.
// Helper method to generate a new certificate authority using the provided // common name and signer .
func NewCA(commonName string, signer crypto.Signer) (*x509.Certificate, error) {
	template := &x509.Certificate{}
	if err := assetTagCertificate(template); err != nil {
		return nil, errors.Annotate(err, "failed tagging new CA certificate")
	}
	template.Subject = pkix.Name{
		CommonName:   commonName,
		Organization: Organisation,
	}
	now := time.Now()
	template.NotBefore = now.Add(NotBeforeJitter)
	template.NotAfter = now.AddDate(DefaultValidityYears, 0, 0)
	template.KeyUsage = x509.KeyUsageKeyEncipherment |
		x509.KeyUsageDigitalSignature |
		x509.KeyUsageCertSign
	template.BasicConstraintsValid = true
	template.IsCA = true
	der, err := x509.CreateCertificate(rand.Reader, template, template,
		signer.Public(), signer)
	if err != nil {
		return nil, errors.Annotate(err, "failed creating CA certificate")
	}
	caCert, err := x509.ParseCertificate(der)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return caCert, nil
}
func NewCA ( commonName string , signer crypto . Signer ) ( * x509 . Certificate , error ) { template := & x509 . Certificate { } if err := assetTagCertificate ( template ) ; err != nil { return nil , errors . Annotate ( err , " " ) } template . Subject = pkix . Name { CommonName : commonName , Organization : Organisation , } now := time . Now ( ) template . NotBefore = now . Add ( NotBeforeJitter ) template . NotAfter = now . AddDate ( DefaultValidityYears , 0 , 0 ) template . KeyUsage = x509 . KeyUsageKeyEncipherment | x509 . KeyUsageDigitalSignature | x509 . KeyUsageCertSign template . BasicConstraintsValid = true template . IsCA = true der , err := x509 . CreateCertificate ( rand . Reader , template , template , signer . Public ( ) , signer ) if err != nil { return nil , errors . Annotate ( err , " " ) } caCert , err := x509 . ParseCertificate ( der ) if err != nil { return nil , errors . Trace ( err ) } return caCert , nil }
Helper method to generate a new certificate authority using the provided
common name and signer.
Helper method to generate a new certificate authority using the provided common name and signer .