2015-06-08 00:36:07 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
2015-06-12 21:34:49 +00:00
|
|
|
"path"
|
2015-06-08 00:36:07 +00:00
|
|
|
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Logger is used to log errors; if nil, the default log.Logger is used.
|
|
|
|
var Logger *log.Logger
|
|
|
|
|
|
|
|
// logger is an helper function to retrieve the available logger
|
|
|
|
func logger() *log.Logger {
|
|
|
|
if Logger == nil {
|
|
|
|
Logger = log.New(os.Stderr, "", log.LstdFlags)
|
|
|
|
}
|
|
|
|
return Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "lego"
|
|
|
|
app.Usage = "Let's encrypt client to go!"
|
2015-12-03 18:41:04 +00:00
|
|
|
app.Version = "0.1.0"
|
2015-06-08 00:36:07 +00:00
|
|
|
|
2015-06-12 21:34:49 +00:00
|
|
|
cwd, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
logger().Fatal("Could not determine current working directory. Please pass --path.")
|
|
|
|
}
|
|
|
|
defaultPath := path.Join(cwd, ".lego")
|
|
|
|
|
2015-06-08 00:36:07 +00:00
|
|
|
app.Commands = []cli.Command{
|
|
|
|
{
|
|
|
|
Name: "run",
|
2015-09-27 12:50:45 +00:00
|
|
|
Usage: "Register an account, then create and install a certificate",
|
2015-06-08 00:36:07 +00:00
|
|
|
Action: run,
|
|
|
|
},
|
|
|
|
{
|
2015-09-27 12:50:45 +00:00
|
|
|
Name: "revoke",
|
|
|
|
Usage: "Revoke a certificate",
|
|
|
|
Action: revoke,
|
2015-06-08 00:36:07 +00:00
|
|
|
},
|
2015-10-18 22:42:04 +00:00
|
|
|
{
|
|
|
|
Name: "renew",
|
|
|
|
Usage: "Renew a certificate",
|
|
|
|
Action: renew,
|
2015-12-06 21:35:52 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
cli.IntFlag{
|
2015-12-24 08:57:09 +00:00
|
|
|
Name: "days",
|
2015-12-06 21:35:52 +00:00
|
|
|
Value: 0,
|
|
|
|
Usage: "The number of days left on a certificate to renew it.",
|
|
|
|
},
|
|
|
|
},
|
2015-10-18 22:42:04 +00:00
|
|
|
},
|
2015-06-08 00:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.StringSliceFlag{
|
|
|
|
Name: "domains, d",
|
|
|
|
Usage: "Add domains to the process",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "server, s",
|
2015-12-03 18:37:54 +00:00
|
|
|
Value: "https://acme-v01.api.letsencrypt.org/directory",
|
2015-06-08 00:36:07 +00:00
|
|
|
Usage: "CA hostname (and optionally :port). The server certificate must be trusted in order to avoid further modifications to the client.",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "email, m",
|
|
|
|
Usage: "Email used for registration and recovery contact.",
|
|
|
|
},
|
|
|
|
cli.IntFlag{
|
|
|
|
Name: "rsa-key-size, B",
|
|
|
|
Value: 2048,
|
|
|
|
Usage: "Size of the RSA key.",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
2015-06-12 21:34:49 +00:00
|
|
|
Name: "path",
|
|
|
|
Usage: "Directory to use for storing the data",
|
|
|
|
Value: defaultPath,
|
2015-06-08 00:36:07 +00:00
|
|
|
},
|
2015-12-05 21:01:08 +00:00
|
|
|
cli.StringSliceFlag{
|
2015-12-27 17:30:04 +00:00
|
|
|
Name: "exclude, x",
|
|
|
|
Usage: "Explicitly disallow solvers by name from being used. Solvers: \"http-01\", \"tls-sni-01\".",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "httpPort",
|
|
|
|
Usage: "Set the port to use for HTTP based challenges to listen on.",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "tlsPort",
|
|
|
|
Usage: "Set the port to use for TLS based challenges to listen on.",
|
2015-06-12 22:16:49 +00:00
|
|
|
},
|
2015-06-08 00:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Run(os.Args)
|
|
|
|
}
|