func GenerateCA(commonName, organizationalUnit string) (*CA, error) {
	cfg := &CertCfg{
		Subject:      pkix.Name{CommonName: commonName, OrganizationalUnit: []string{organizationalUnit}},
		KeyUsages:    x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
		ExtKeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
		Validity:     ValidityTenYears,
		IsCA:         true,
	}

	key, crt, err := GenerateSelfSignedCertificate(cfg)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to generate CA with cn=%s,ou=%s", commonName, organizationalUnit)
	}
	return &CA{Key: key, Cert: crt}, nil
}
// GenerateCA generates a CA key pair with the given filename
GenerateCA generates a CA key pair with the given filename
// GenerateCA generates a CA key pair with the given filename
func GenerateCA(commonName, organizationalUnit string) (*CA, error) {
	cfg := &CertCfg{
		Subject:      pkix.Name{CommonName: commonName, OrganizationalUnit: []string{organizationalUnit}},
		KeyUsages:    x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
		ExtKeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
		Validity:     ValidityTenYears,
		IsCA:         true,
	}
	key, crt, err := GenerateSelfSignedCertificate(cfg)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to generate CA with cn=%s,ou=%s", commonName, organizationalUnit)
	}
	return &CA{Key: key, Cert: crt}, nil
}
func GenerateCA ( commonName , organizationalUnit string ) ( * CA , error ) { cfg := & CertCfg { Subject : pkix . Name { CommonName : commonName , OrganizationalUnit : [ ] string { organizationalUnit } } , KeyUsages : x509 . KeyUsageKeyEncipherment | x509 . KeyUsageDigitalSignature | x509 . KeyUsageCertSign , ExtKeyUsages : [ ] x509 . ExtKeyUsage { x509 . ExtKeyUsageClientAuth , x509 . ExtKeyUsageServerAuth } , Validity : ValidityTenYears , IsCA : true , } key , crt , err := GenerateSelfSignedCertificate ( cfg ) if err != nil { return nil , errors . Wrapf ( err , " " , commonName , organizationalUnit ) } return & CA { Key : key , Cert : crt } , nil }
GenerateCA generates a CA key pair with the given filename
GenerateCA generates a CA key pair with the given filename