package traefikv3 import ( "crypto" "crypto/x509" "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/registration" ) // StoredData represents the data managed by Store. type StoredData struct { Account *Account Certificates []*CertAndStore } // Account is used to store lets encrypt registration info. type Account struct { Email string Registration *registration.Resource PrivateKey []byte KeyType certcrypto.KeyType } // GetEmail returns email. func (a *Account) GetEmail() string { return a.Email } // GetRegistration returns lets encrypt registration resource. func (a *Account) GetRegistration() *registration.Resource { return a.Registration } // GetPrivateKey returns private key. func (a *Account) GetPrivateKey() crypto.PrivateKey { privateKey, err := x509.ParsePKCS1PrivateKey(a.PrivateKey) if err != nil { return nil } return privateKey } // CertAndStore allows mapping a TLS certificate to a TLS store. type CertAndStore struct { Certificate Store string } // Certificate is a struct which contains all data needed from an ACME certificate. type Certificate struct { Domain Domain `json:"domain,omitempty" toml:"domain,omitempty" yaml:"domain,omitempty"` Certificate []byte `json:"certificate,omitempty" toml:"certificate,omitempty" yaml:"certificate,omitempty"` Key []byte `json:"key,omitempty" toml:"key,omitempty" yaml:"key,omitempty"` } // Domain holds a domain name with SANs. type Domain struct { // Main defines the main domain name. Main string `description:"Default subject name." json:"main,omitempty" toml:"main,omitempty" yaml:"main,omitempty"` // SANs defines the subject alternative domain names. SANs []string `description:"Subject alternative names." json:"sans,omitempty" toml:"sans,omitempty" yaml:"sans,omitempty"` } // ToStrArray convert a domain into an array of strings. func (d *Domain) ToStrArray() []string { var domains []string if d.Main != "" { domains = []string{d.Main} } return append(domains, d.SANs...) } // Set sets a domains from an array of strings. func (d *Domain) Set(domains []string) { if len(domains) > 0 { d.Main = domains[0] d.SANs = domains[1:] } } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (d *Domain) DeepCopyInto(out *Domain) { *out = *d if d.SANs != nil { in, out := &d.SANs, &out.SANs *out = make([]string, len(*in)) copy(*out, *in) } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Domain. func (d *Domain) DeepCopy() *Domain { if d == nil { return nil } out := new(Domain) d.DeepCopyInto(out) return out }