Skip to content

Commit

Permalink
minor: fix the bug of certificate cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jinrenjie committed Sep 15, 2024
1 parent 2810aca commit 72878a9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ func (s *Server) Run(verbose bool, errChan chan error) {
provider := challenge.NewChallengeProvider(dns.Servers)
storage := certmagic.FileStorage{Path: config.Conf.Providers.ACME.Storage}

certmagic.DefaultACME.DNS01Solver = &provider
certmagic.DefaultACME.Agreed = true
certmagic.DefaultACME.CA = config.Conf.Providers.ACME.Server
certmagic.DefaultACME.TestCA = config.Conf.Providers.ACME.Server
certmagic.DefaultACME.Agreed = true
certmagic.DefaultACME.Email = config.Conf.Providers.ACME.Email
certmagic.DefaultACME.Logger = journal.Logger
certmagic.DefaultACME.DNS01Solver = &provider

magicConf := &certmagic.Config{}
magicConf.OCSP = certmagic.OCSPConfig{
Expand All @@ -103,15 +104,15 @@ func (s *Server) Run(verbose bool, errChan chan error) {
},
})

magic := certmagic.New(magicCache, *magicConf)
magicConf = certmagic.New(magicCache, *magicConf)

err := magic.ManageAsync(context.Background(), []string{config.Conf.HTTP.Domain})
err := magicConf.ManageAsync(context.Background(), []string{config.Conf.HTTP.Domain})
if err != nil {
errChan <- err
return
}

tlsConf.GetCertificate = magic.GetCertificate
tlsConf.GetCertificate = magicConf.GetCertificate
tlsConf.NextProtos = []string{"http/1.1", "acme-tls/1"}

// Create custom listener
Expand Down

0 comments on commit 72878a9

Please sign in to comment.