func (e *Etcd) Generate(rootCA *Certificate, defaultCertificate Certificate) error {
	if e.CA == nil {
		e.CA = &Certificate{}
	}
	servers := e.Servers
	if e.Servers == nil && e.Peers != nil {
		servers = e.Peers
	}
	e.initializeCertificatesMaps(servers)
	cr := &certificateRequest{
		Target: e.CA,
		CA:     rootCA,
		Certificates: []*Certificate{
			&defaultCertificate,
			&e.Certificate,
			caCertificate(EtcdCACN),
			e.CA,
		},
	}
	if err := buildAndGenerate(cr); err != nil {
		return fmt.Errorf("generating etcd CA certificate: %w", err)
	}
	crs := []*certificateRequest{}
	crs = append(crs, e.crsFromMap(&defaultCertificate, e.PeerCertificates, e.Peers, true)...)
	crs = append(crs, e.crsFromMap(&defaultCertificate, e.ServerCertificates, servers, true)...)
	clientCNsMap := map[string]string{}
	for _, commonName := range e.ClientCNs {
		clientCNsMap[commonName] = ""
	}
	crs = append(crs, e.crsFromMap(&defaultCertificate, e.ClientCertificates, clientCNsMap, false)...)
	return buildAndGenerate(crs...)
}
Generate generates etcd PKI.
package pki
import (
	"fmt"
)
const (
	EtcdCACN = "etcd-ca"
)
type Etcd struct {
	Certificate
	CA *Certificate `json:"ca,omitempty"`
	Peers map[string]string `json:"peers,omitempty"`
	Servers map[string]string `json:"servers,omitempty"`
	ClientCNs []string `json:"clientCNs,omitempty"`
	PeerCertificates map[string]*Certificate `json:"peerCertificates,omitempty"`
	ServerCertificates map[string]*Certificate `json:"serverCertificates,omitempty"`
	ClientCertificates map[string]*Certificate `json:"clientCertificates,omitempty"`
}