mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-01 01:22:34 +02:00
feat(autocert): add CACerts field to autocert Config for custom CA
This commit is contained in:
parent
8469b6406c
commit
9d58977fa6
1 changed files with 9 additions and 0 deletions
|
@ -26,6 +26,7 @@ type Config struct {
|
|||
ACMEKeyPath string `json:"acme_key_path,omitempty"`
|
||||
Provider string `json:"provider,omitempty"`
|
||||
CADirURL string `json:"ca_dir_url,omitempty"`
|
||||
CACerts []string `json:"ca_certs,omitempty"`
|
||||
Options map[string]any `json:"options,omitempty"`
|
||||
|
||||
HTTPClient *http.Client `json:"-"` // for tests only
|
||||
|
@ -151,6 +152,14 @@ func (cfg *Config) GetLegoConfig() (*User, *lego.Config, gperr.Error) {
|
|||
legoCfg.CADirURL = cfg.CADirURL
|
||||
}
|
||||
|
||||
if len(cfg.CACerts) > 0 {
|
||||
certPool, err := lego.CreateCertPool(cfg.CACerts, true)
|
||||
if err != nil {
|
||||
return nil, nil, gperr.New("failed to create cert pool").With(err)
|
||||
}
|
||||
legoCfg.HTTPClient.Transport.(*http.Transport).TLSClientConfig.RootCAs = certPool
|
||||
}
|
||||
|
||||
return user, legoCfg, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue