fix: update dependency certmagic (#1625)

module github.com/mholt/certmagic has been renamed github.com/caddyserver/certmagic,
so upgrade on this module will fail.

fix: micro/micro#835

caddyserver/certmagic@v0.10.6 is Maximum upgradeable version with go version 1.13

Higher version use *tls.ClientHelloInfo.SupportsCertificate which only supported in go 1.14
This commit is contained in:
x1nchen
2020-05-13 22:00:13 +08:00
committed by GitHub
parent fb255a7e5a
commit af2db0a0d9
4 changed files with 19 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
// Package certmagic is the ACME provider from github.com/mholt/certmagic
// Package certmagic is the ACME provider from github.com/caddyserver/certmagic
package certmagic
import (
@@ -7,7 +7,7 @@ import (
"net"
"time"
"github.com/mholt/certmagic"
"github.com/caddyserver/certmagic"
"github.com/micro/go-micro/v2/api/server/acme"
"github.com/micro/go-micro/v2/logger"
)
@@ -18,10 +18,10 @@ type certmagicProvider struct {
// TODO: set self-contained options
func (c *certmagicProvider) setup() {
certmagic.Default.CA = c.opts.CA
certmagic.DefaultACME.CA = c.opts.CA
if c.opts.ChallengeProvider != nil {
// Enabling DNS Challenge disables the other challenges
certmagic.Default.DNSProvider = c.opts.ChallengeProvider
certmagic.DefaultACME.DNSProvider = c.opts.ChallengeProvider
}
if c.opts.OnDemand {
certmagic.Default.OnDemand = new(certmagic.OnDemandConfig)
@@ -32,9 +32,10 @@ func (c *certmagicProvider) setup() {
}
// If multiple instances of the provider are running, inject some
// randomness so they don't collide
// RenewalWindowRatio [0.33 - 0.50)
rand.Seed(time.Now().UnixNano())
randomDuration := (7 * 24 * time.Hour) + (time.Duration(rand.Intn(504)) * time.Hour)
certmagic.Default.RenewDurationBefore = randomDuration
randomRatio := float64(rand.Intn(17) + 33) * 0.01
certmagic.Default.RenewalWindowRatio = randomRatio
}
func (c *certmagicProvider) Listen(hosts ...string) (net.Listener, error) {

View File

@@ -9,7 +9,7 @@ import (
"strings"
"time"
"github.com/mholt/certmagic"
"github.com/caddyserver/certmagic"
"github.com/micro/go-micro/v2/store"
"github.com/micro/go-micro/v2/sync"
)