mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 10:01:30 +00:00
Fix certmagic usage
This commit is contained in:
parent
e0058ca9c5
commit
407cf68e59
|
@ -21,6 +21,7 @@ import (
|
||||||
type acmeWrapper struct {
|
type acmeWrapper struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
cfg *certmagic.Config
|
cfg *certmagic.Config
|
||||||
|
cache *certmagic.Cache
|
||||||
domain []string
|
domain []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ func (w *acmeWrapper) Start() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *acmeWrapper) Close() error {
|
func (w *acmeWrapper) Close() error {
|
||||||
w.cfg.Unmanage(w.domain)
|
w.cache.Stop()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,10 +78,11 @@ func startACME(ctx context.Context, options option.InboundACMEOptions) (*tls.Con
|
||||||
acmeConfig.ExternalAccount = (*acme.EAB)(options.ExternalAccount)
|
acmeConfig.ExternalAccount = (*acme.EAB)(options.ExternalAccount)
|
||||||
}
|
}
|
||||||
config.Issuers = []certmagic.Issuer{certmagic.NewACMEIssuer(config, acmeConfig)}
|
config.Issuers = []certmagic.Issuer{certmagic.NewACMEIssuer(config, acmeConfig)}
|
||||||
config = certmagic.New(certmagic.NewCache(certmagic.CacheOptions{
|
cache := certmagic.NewCache(certmagic.CacheOptions{
|
||||||
GetConfigForCert: func(certificate certmagic.Certificate) (*certmagic.Config, error) {
|
GetConfigForCert: func(certificate certmagic.Certificate) (*certmagic.Config, error) {
|
||||||
return config, nil
|
return config, nil
|
||||||
},
|
},
|
||||||
}), *config)
|
})
|
||||||
return config.TLSConfig(), &acmeWrapper{ctx, config, options.Domain}, nil
|
config = certmagic.New(cache, *config)
|
||||||
|
return config.TLSConfig(), &acmeWrapper{ctx: ctx, cfg: config, cache: cache, domain: options.Domain}, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue