// GenerateCSRCertificate returns an x509 Certificate from a CSR, signing cert, public key, signing private key and duration.
GenerateCSRCertificate returns an x509 Certificate from a CSR, signing cert, public key, signing private key and duration.
// GenerateCSRCertificate returns an x509 Certificate from a CSR signing cert public key signing private key and duration .
func GenerateCSRCertificate(csr *x509.CertificateRequest, subject string, signingCert *x509.Certificate, publicKey interface{}, signingKey crypto.PrivateKey,
	ttl time.Duration, isCA bool) ([]byte, error) {
	cert, err := generateBaseCert(ttl, publicKey)
	if err != nil {
		return nil, fmt.Errorf("error generating csr certificate: %s", err)
	}
	if isCA {
		cert.KeyUsage = x509.KeyUsageCertSign | x509.KeyUsageCRLSign
	} else {
		cert.KeyUsage = x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment
		cert.ExtKeyUsage = append(cert.ExtKeyUsage, x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth)
	}
	cert.Subject = pkix.Name{
		CommonName: subject,
	}
	cert.Issuer = signingCert.Issuer
	cert.IsCA = isCA
	cert.DNSNames = csr.DNSNames
	cert.IPAddresses = csr.IPAddresses
	cert.Extensions = csr.Extensions
	cert.BasicConstraintsValid = true
	cert.SignatureAlgorithm = csr.SignatureAlgorithm
	return x509.CreateCertificate(rand.Reader, cert, signingCert, publicKey, signingKey)
}
func GenerateCSRCertificate ( csr * x509 . CertificateRequest , subject string , signingCert * x509 . Certificate , publicKey interface { } , signingKey crypto . PrivateKey , ttl time . Duration , isCA bool ) ( [ ] byte , error ) { cert , err := generateBaseCert ( ttl , publicKey ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if isCA { cert . KeyUsage = x509 . KeyUsageCertSign | x509 . KeyUsageCRLSign } else { cert . KeyUsage = x509 . KeyUsageDigitalSignature | x509 . KeyUsageKeyEncipherment cert . ExtKeyUsage = append ( cert . ExtKeyUsage , x509 . ExtKeyUsageServerAuth , x509 . ExtKeyUsageClientAuth ) } cert . Subject = pkix . Name { CommonName : subject , } cert . Issuer = signingCert . Issuer cert . IsCA = isCA cert . DNSNames = csr . DNSNames cert . IPAddresses = csr . IPAddresses cert . Extensions = csr . Extensions cert . BasicConstraintsValid = true cert . SignatureAlgorithm = csr . SignatureAlgorithm return x509 . CreateCertificate ( rand . Reader , cert , signingCert , publicKey , signingKey ) }
GenerateCSRCertificate returns an x509 Certificate from a CSR, signing cert, public key, signing private key and duration.
GenerateCSRCertificate returns an x509 Certificate from a CSR signing cert public key signing private key and duration .