dousou2911 2018-11-16 11:42
浏览 86
已采纳

acme autocert管理器在启动时会忽略有效的证书

I'm building currently a service that uses acme/autocert. To use that service with more than 1 replicas, I had to write a persistent cache interface like DirCache. Then I noticed, that after restarting the service all valid certs in the Cache got ignored on the startup. The following sequence happens all the time:

  • Cache put acme_account+key (even if it exists in the cache)
  • Cache get acme_account+key
  • Cache get my.domain.net (it returns the cached cert)
  • Cache get acme_account+key
  • Cache put my.domain.net+token
  • Cache put HASH+http-01
  • Cache delete HASH+http-01
  • Cache delete my.domain.net+token
  • Cache put my.domain.net (put the new cert)

Is this the correct behavior? Because every replica would create its own cert and a persistent Cache is not possible with this circumstances

Here is my manager factory

func NewManager(d *db.DynamoDB, staging bool) *Manager {
    manager := &Manager{
        CertCache: NewPersistentCertCache(d),
    }

    directoryURL := acme.LetsEncryptURL
    if staging {
        directoryURL = LetsEncryptStagingURL
        log.Infof("Using CA staging environment")
    }
    log.Infof("CA URI %s", directoryURL)

    client := &acme.Client{
        DirectoryURL: directoryURL,
    }

    manager.AcmeManager = &autocert.Manager{
        Prompt:     autocert.AcceptTOS,
        HostPolicy: manager.AllowHostPolicy,
        Cache:      manager.CertCache,
        Client:     client,
    }

    return manager
}
  • 写回答

1条回答 默认 最新

  • dongyied24121 2018-11-21 11:46
    关注

    The solution for this question is that the cache interface and behavior works correctly. My cache implementation was faulty. I had a goroutine within the Cache.Get(...) that read from a DB to a channel, but unfortunately the outer func body did not wait for that channel and returns always a CacheMissed error. After the fix everything works fine. My fault sry

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看