fix: multiple resolvers.
This commit is contained in:
parent
f8e2d89d6c
commit
574db1a1e0
@ -35,7 +35,7 @@
|
|||||||
exclude-use-default = false
|
exclude-use-default = false
|
||||||
max-per-linter = 0
|
max-per-linter = 0
|
||||||
max-same-issues = 0
|
max-same-issues = 0
|
||||||
exclude = []
|
exclude = ["ST1000: at least one file in a package should have a package comment"]
|
||||||
[[issues.exclude-rules]]
|
[[issues.exclude-rules]]
|
||||||
path = "cmd/"
|
path = "cmd/"
|
||||||
linters = ["gochecknoglobals", "gochecknoinits"]
|
linters = ["gochecknoglobals", "gochecknoinits"]
|
||||||
|
|||||||
@ -60,8 +60,8 @@ func dumpV2(acmeFile string, baseConfig *dumper.BaseConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
data := &acme.StoredData{}
|
data := map[string]*acme.StoredData{}
|
||||||
if err = json.NewDecoder(source).Decode(data); err != nil {
|
if err = json.NewDecoder(source).Decode(&data); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Dump Dumps data to certificates.
|
// Dump Dumps data to certificates.
|
||||||
func Dump(data *acme.StoredData, baseConfig *dumper.BaseConfig) error {
|
func Dump(data map[string]*acme.StoredData, baseConfig *dumper.BaseConfig) error {
|
||||||
if baseConfig.Clean {
|
if baseConfig.Clean {
|
||||||
err := cleanDir(baseConfig.DumpPath)
|
err := cleanDir(baseConfig.DumpPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -35,24 +35,32 @@ func Dump(data *acme.StoredData, baseConfig *dumper.BaseConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, cert := range data.Certificates {
|
for _, store := range data {
|
||||||
err := writeCert(baseConfig.DumpPath, cert.Certificate, baseConfig.CrtInfo, baseConfig.DomainSubDir)
|
for _, cert := range store.Certificates {
|
||||||
if err != nil {
|
err := writeCert(baseConfig.DumpPath, cert.Certificate, baseConfig.CrtInfo, baseConfig.DomainSubDir)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = writeKey(baseConfig.DumpPath, cert.Certificate, baseConfig.KeyInfo, baseConfig.DomainSubDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = writeKey(baseConfig.DumpPath, cert.Certificate, baseConfig.KeyInfo, baseConfig.DomainSubDir)
|
if store.Account == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
privateKeyPem := extractPEMPrivateKey(store.Account)
|
||||||
|
|
||||||
|
err := ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.Account == nil {
|
return nil
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
privateKeyPem := extractPEMPrivateKey(data.Account)
|
|
||||||
return ioutil.WriteFile(filepath.Join(baseConfig.DumpPath, keysSubDir, "letsencrypt"+baseConfig.KeyInfo.Ext), privateKeyPem, 0600)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeCert(dumpPath string, cert acme.Certificate, info dumper.FileInfo, domainSubDir bool) error {
|
func writeCert(dumpPath string, cert acme.Certificate, info dumper.FileInfo, domainSubDir bool) error {
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
package v2
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/go-acme/lego/v3/certcrypto"
|
|
||||||
"github.com/go-acme/lego/v3/registration"
|
|
||||||
)
|
|
||||||
|
|
||||||
// StoredData represents the data managed by the Store
|
|
||||||
type StoredData struct {
|
|
||||||
Account *Account
|
|
||||||
Certificates []*Certificate
|
|
||||||
HTTPChallenges map[string]map[string][]byte
|
|
||||||
TLSChallenges map[string]*Certificate
|
|
||||||
}
|
|
||||||
|
|
||||||
// Certificate is a struct which contains all data needed from an ACME certificate
|
|
||||||
type Certificate struct {
|
|
||||||
Domain Domain `json:"domain,omitempty"`
|
|
||||||
Certificate []byte `json:"certificate,omitempty"`
|
|
||||||
Key []byte `json:"key,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Domain holds a domain name with SANs
|
|
||||||
type Domain struct {
|
|
||||||
Main string `json:"main,omitempty"`
|
|
||||||
SANs []string `json:"sans,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Account is used to store lets encrypt registration info
|
|
||||||
type Account struct {
|
|
||||||
Email string
|
|
||||||
Registration *registration.Resource
|
|
||||||
PrivateKey []byte
|
|
||||||
KeyType certcrypto.KeyType
|
|
||||||
}
|
|
||||||
@ -19,7 +19,6 @@ func Test_execute(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
t.Run(test.desc, func(t *testing.T) {
|
t.Run(test.desc, func(t *testing.T) {
|
||||||
|
|
||||||
err := execute(test.command)
|
err := execute(test.command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user