1
0
mirror of https://github.com/go-acme/lego.git synced 2024-12-25 11:02:56 +02:00

Add a dev flag for skipping challenge pre-checks

This commit is contained in:
xenolf 2015-10-18 01:57:46 +02:00
parent 835927f5d5
commit b49f37d920
3 changed files with 14 additions and 5 deletions

View File

@ -45,11 +45,16 @@ type Client struct {
user User
jws *jws
keyBits int
devMode bool
solvers map[string]solver
}
// NewClient creates a new client for the set user.
func NewClient(caURL string, usr User, keyBits int, optPort string) *Client {
// caURL - The root url to the boulder instance you want certificates from
// usr - A filled in user struct
// optPort - The alternative port to listen on for challenges.
// devMode - If set to true, all CanSolve() checks are skipped.
func NewClient(caURL string, usr User, keyBits int, optPort string, devMode bool) *Client {
if err := usr.GetPrivateKey().Validate(); err != nil {
logger().Fatalf("Could not validate the private account key of %s\n\t%v", usr.GetEmail(), err)
}
@ -75,7 +80,7 @@ func NewClient(caURL string, usr User, keyBits int, optPort string) *Client {
logger().Fatal("The directory returned by the server was invalid.")
}
return &Client{directory: dir, user: usr, jws: jws, keyBits: keyBits, solvers: solvers}
return &Client{directory: dir, user: usr, jws: jws, keyBits: keyBits, devMode: devMode, solvers: solvers}
}
// Register the current account to the ACME server.
@ -207,7 +212,7 @@ func (c *Client) chooseSolvers(auth authorization, domain string) map[int]solver
for _, combination := range auth.Combinations {
solvers := make(map[int]solver)
for _, idx := range combination {
if solver, ok := c.solvers[auth.Challenges[idx].Type]; ok && solver.CanSolve(domain) {
if solver, ok := c.solvers[auth.Challenges[idx].Type]; ok && (c.devMode || solver.CanSolve(domain)) {
solvers[idx] = solver
} else {
logger().Printf("Could not find solver for: %s", auth.Challenges[idx].Type)

4
cli.go
View File

@ -80,6 +80,10 @@ func main() {
Name: "port",
Usage: "Challenges will use this port to listen on. Please make sure to forward port 443 to this port on your machine. Otherwise use setcap on the binary",
},
cli.BoolFlag{
Name: "devMode",
Usage: "If set to true, all client side challenge pre-tests are skipped.",
},
}
app.Run(os.Args)

View File

@ -32,7 +32,7 @@ func run(c *cli.Context) {
}
acc := NewAccount(c.GlobalString("email"), conf)
client := acme.NewClient(c.GlobalString("server"), acc, conf.RsaBits(), conf.OptPort())
client := acme.NewClient(c.GlobalString("server"), acc, conf.RsaBits(), conf.OptPort(), c.GlobalBool("devMode"))
if acc.Registration == nil {
reg, err := client.Register()
if err != nil {
@ -126,7 +126,7 @@ func revoke(c *cli.Context) {
}
acc := NewAccount(c.GlobalString("email"), conf)
client := acme.NewClient(c.GlobalString("server"), acc, conf.RsaBits(), conf.OptPort())
client := acme.NewClient(c.GlobalString("server"), acc, conf.RsaBits(), conf.OptPort(), c.GlobalBool("devMode"))
err = checkFolder(conf.CertPath())
if err != nil {