Skip to content

Commit

Permalink
fix ondemand cert issuing (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanovart authored Sep 11, 2022
1 parent c49a1ca commit 7aecd2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion httpmuxer/httpmuxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ func Start(state *utils.State) {
gin.WrapH(currentListener.Balancer)(c)
})

var acmeIssuer *certmagic.ACMEIssuer = nil

// If HTTPS is enabled, setup certmagic to allow us to provision HTTPS certs on the fly.
// You can use sish without a wildcard cert, but you really should. If you get a lot of clients
// with many random subdomains, you'll burn through your Let's Encrypt quota. Be careful!
Expand All @@ -289,7 +291,7 @@ func Start(state *utils.State) {

certManager := certmagic.NewDefault()

acmeIssuer := certmagic.NewACMEIssuer(certManager, certmagic.DefaultACME)
acmeIssuer = certmagic.NewACMEIssuer(certManager, certmagic.DefaultACME)

acmeIssuer.Agreed = viper.GetBool("https-ondemand-certificate-accept-terms")
acmeIssuer.Email = viper.GetString("https-ondemand-certificate-email")
Expand Down Expand Up @@ -404,6 +406,9 @@ func Start(state *utils.State) {
Addr: viper.GetString("http-address"),
Handler: r,
}
if acmeIssuer != nil {
httpServer.Handler = acmeIssuer.HTTPChallengeHandler(r)
}

var httpListener net.Listener

Expand Down

0 comments on commit 7aecd2d

Please sign in to comment.