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 user User
jws *jws jws *jws
keyBits int keyBits int
devMode bool
solvers map[string]solver solvers map[string]solver
} }
// NewClient creates a new client for the set user. // 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 { if err := usr.GetPrivateKey().Validate(); err != nil {
logger().Fatalf("Could not validate the private account key of %s\n\t%v", usr.GetEmail(), err) 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.") 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. // 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 { for _, combination := range auth.Combinations {
solvers := make(map[int]solver) solvers := make(map[int]solver)
for _, idx := range combination { 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 solvers[idx] = solver
} else { } else {
logger().Printf("Could not find solver for: %s", auth.Challenges[idx].Type) 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", 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", 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) app.Run(os.Args)

View file

@ -32,7 +32,7 @@ func run(c *cli.Context) {
} }
acc := NewAccount(c.GlobalString("email"), conf) 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 { if acc.Registration == nil {
reg, err := client.Register() reg, err := client.Register()
if err != nil { if err != nil {
@ -126,7 +126,7 @@ func revoke(c *cli.Context) {
} }
acc := NewAccount(c.GlobalString("email"), conf) 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()) err = checkFolder(conf.CertPath())
if err != nil { if err != nil {