func (ca *CAServer) leafCert(csr *x509.CertificateRequest) (der []byte, err error) {
	ca.certCount++ // next leaf cert serial number
	leaf := &x509.Certificate{
		SerialNumber:          big.NewInt(int64(ca.certCount)),
		Subject:               pkix.Name{Organization: []string{"Test Acme Co"}},
		NotBefore:             time.Now(),
		NotAfter:              time.Now().Add(90 * 24 * time.Hour),
		KeyUsage:              x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,
		ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
		DNSNames:              csr.DNSNames,
		BasicConstraintsValid: true,
	}
	if len(csr.DNSNames) == 0 {
		leaf.DNSNames = []string{csr.Subject.CommonName}
	}
	return x509.CreateCertificate(rand.Reader, leaf, ca.rootTemplate, csr.PublicKey, ca.rootKey)
}
// leafCert issues a new certificate.
// It requires ca.mu to be locked.
leafCert issues a new certificate.
It requires ca.mu to be locked.
// leafCert issues a new certificate . // It requires ca . mu to be locked .
func (ca *CAServer) leafCert(csr *x509.CertificateRequest) (der []byte, err error) {
	ca.certCount++ 
	leaf := &x509.Certificate{
		SerialNumber:          big.NewInt(int64(ca.certCount)),
		Subject:               pkix.Name{Organization: []string{"Test Acme Co"}},
		NotBefore:             time.Now(),
		NotAfter:              time.Now().Add(90 * 24 * time.Hour),
		KeyUsage:              x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment,
		ExtKeyUsage:           []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
		DNSNames:              csr.DNSNames,
		BasicConstraintsValid: true,
	}
	if len(csr.DNSNames) == 0 {
		leaf.DNSNames = []string{csr.Subject.CommonName}
	}
	return x509.CreateCertificate(rand.Reader, leaf, ca.rootTemplate, csr.PublicKey, ca.rootKey)
}
func ( ca * CAServer ) leafCert ( csr * x509 . CertificateRequest ) ( der [ ] byte , err error ) { ca . certCount ++ leaf := & x509 . Certificate { SerialNumber : big . NewInt ( int64 ( ca . certCount ) ) , Subject : pkix . Name { Organization : [ ] string { " " } } , NotBefore : time . Now ( ) , NotAfter : time . Now ( ) . Add ( 90 * 24 * time . Hour ) , KeyUsage : x509 . KeyUsageDigitalSignature | x509 . KeyUsageKeyEncipherment , ExtKeyUsage : [ ] x509 . ExtKeyUsage { x509 . ExtKeyUsageServerAuth } , DNSNames : csr . DNSNames , BasicConstraintsValid : true , } if len ( csr . DNSNames ) == 0 { leaf . DNSNames = [ ] string { csr . Subject . CommonName } } return x509 . CreateCertificate ( rand . Reader , leaf , ca . rootTemplate , csr . PublicKey , ca . rootKey ) }
leafCert issues a new certificate.
leafCert issues a new certificate .
// next leaf cert serial number