2019-03-11 16:56:48 +00:00
|
|
|
package cmd
|
2018-12-06 21:50:17 +00:00
|
|
|
|
|
|
|
import (
|
2023-05-28 14:45:48 +00:00
|
|
|
"time"
|
|
|
|
|
2024-06-13 20:48:04 +00:00
|
|
|
"github.com/go-acme/lego/v4/certificate"
|
2020-09-02 01:20:01 +00:00
|
|
|
"github.com/go-acme/lego/v4/lego"
|
2022-02-13 11:28:51 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"software.sslmate.com/src/go-pkcs12"
|
2018-12-06 21:50:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func CreateFlags(defaultPath string) []cli.Flag {
|
|
|
|
return []cli.Flag{
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringSliceFlag{
|
|
|
|
Name: "domains",
|
|
|
|
Aliases: []string{"d"},
|
|
|
|
Usage: "Add a domain to the process. Can be specified multiple times.",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "server",
|
|
|
|
Aliases: []string{"s"},
|
2024-01-12 21:11:42 +00:00
|
|
|
EnvVars: []string{"LEGO_SERVER"},
|
2022-02-13 11:28:51 +00:00
|
|
|
Usage: "CA hostname (and optionally :port). The server certificate must be trusted in order to avoid further modifications to the client.",
|
|
|
|
Value: lego.LEDirectoryProduction,
|
|
|
|
},
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "accept-tos",
|
|
|
|
Aliases: []string{"a"},
|
|
|
|
Usage: "By setting this flag to true you indicate that you accept the current Let's Encrypt terms of service.",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "email",
|
|
|
|
Aliases: []string{"m"},
|
|
|
|
Usage: "Email used for registration and recovery contact.",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "csr",
|
|
|
|
Aliases: []string{"c"},
|
|
|
|
Usage: "Certificate signing request filename, if an external CSR is to be used.",
|
|
|
|
},
|
|
|
|
&cli.BoolFlag{
|
2023-07-27 12:07:10 +00:00
|
|
|
Name: "eab",
|
|
|
|
EnvVars: []string{"LEGO_EAB"},
|
|
|
|
Usage: "Use External Account Binding for account registration. Requires --kid and --hmac.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2023-07-27 12:07:10 +00:00
|
|
|
Name: "kid",
|
|
|
|
EnvVars: []string{"LEGO_EAB_KID"},
|
|
|
|
Usage: "Key identifier from External CA. Used for External Account Binding.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2023-07-27 12:07:10 +00:00
|
|
|
Name: "hmac",
|
|
|
|
EnvVars: []string{"LEGO_EAB_HMAC"},
|
|
|
|
Usage: "MAC key from External CA. Should be in Base64 URL Encoding without padding format. Used for External Account Binding.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "key-type",
|
|
|
|
Aliases: []string{"k"},
|
|
|
|
Value: "ec256",
|
2023-03-01 15:27:20 +00:00
|
|
|
Usage: "Key type to use for private keys. Supported: rsa2048, rsa3072, rsa4096, rsa8192, ec256, ec384.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2018-12-06 21:50:17 +00:00
|
|
|
Name: "filename",
|
2019-01-03 15:59:53 +00:00
|
|
|
Usage: "(deprecated) Filename of the generated certificate.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "path",
|
|
|
|
EnvVars: []string{"LEGO_PATH"},
|
|
|
|
Usage: "Directory to use for storing the data.",
|
|
|
|
Value: defaultPath,
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.BoolFlag{
|
2019-01-03 15:59:53 +00:00
|
|
|
Name: "http",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Use the HTTP-01 challenge to solve challenges. Can be mixed with other types of challenges.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2019-01-03 15:59:53 +00:00
|
|
|
Name: "http.port",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Set the port and interface to use for HTTP-01 based challenges to listen on. Supported: interface:port or :port.",
|
2019-01-03 15:59:53 +00:00
|
|
|
Value: ":80",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2019-10-05 11:44:38 +00:00
|
|
|
Name: "http.proxy-header",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Validate against this HTTP header when solving HTTP-01 based challenges behind a reverse proxy.",
|
2019-10-05 11:44:38 +00:00
|
|
|
Value: "Host",
|
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2023-01-08 13:53:15 +00:00
|
|
|
Name: "http.webroot",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Set the webroot folder to use for HTTP-01 based challenges to write directly to the .well-known/acme-challenge file." +
|
2023-01-08 13:53:15 +00:00
|
|
|
" This disables the built-in server and expects the given directory to be publicly served with access to .well-known/acme-challenge",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringSliceFlag{
|
2019-01-03 15:59:53 +00:00
|
|
|
Name: "http.memcached-host",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Set the memcached host(s) to use for HTTP-01 based challenges. Challenges will be written to all specified hosts.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2023-07-27 10:42:48 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "http.s3-bucket",
|
|
|
|
Usage: "Set the S3 bucket name to use for HTTP-01 based challenges. Challenges will be written to the S3 bucket.",
|
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.BoolFlag{
|
2019-01-03 15:59:53 +00:00
|
|
|
Name: "tls",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Use the TLS-ALPN-01 challenge to solve challenges. Can be mixed with other types of challenges.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2019-01-03 15:59:53 +00:00
|
|
|
Name: "tls.port",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Set the port and interface to use for TLS-ALPN-01 based challenges to listen on. Supported: interface:port or :port.",
|
2019-01-03 15:59:53 +00:00
|
|
|
Value: ":443",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2018-12-06 21:50:17 +00:00
|
|
|
Name: "dns",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Solve a DNS-01 challenge using the specified provider. Can be mixed with other types of challenges. Run 'lego dnshelp' for help on usage.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.BoolFlag{
|
2019-01-03 15:59:53 +00:00
|
|
|
Name: "dns.disable-cp",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "By setting this flag to true, disables the need to await propagation of the TXT record to all authoritative name servers.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2024-09-07 19:40:21 +00:00
|
|
|
&cli.DurationFlag{
|
|
|
|
Name: "dns.propagation-wait",
|
|
|
|
Usage: "By setting this flag, disables all the propagation checks and uses a wait duration instead.",
|
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringSliceFlag{
|
2023-01-08 13:53:15 +00:00
|
|
|
Name: "dns.resolvers",
|
2023-01-12 14:07:31 +00:00
|
|
|
Usage: "Set the resolvers to use for performing (recursive) CNAME resolving and apex domain determination." +
|
2023-03-02 22:14:25 +00:00
|
|
|
" For DNS-01 challenge verification, the authoritative DNS server is queried directly." +
|
2023-01-08 13:53:15 +00:00
|
|
|
" Supported: host:port." +
|
|
|
|
" The default is to use the system resolvers, or Google's DNS resolvers if the system's cannot be determined.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.IntFlag{
|
2019-01-03 15:59:53 +00:00
|
|
|
Name: "http-timeout",
|
|
|
|
Usage: "Set the HTTP timeout value to a specific value in seconds.",
|
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.IntFlag{
|
2018-12-06 21:50:17 +00:00
|
|
|
Name: "dns-timeout",
|
2023-03-02 22:14:25 +00:00
|
|
|
Usage: "Set the DNS timeout value to a specific value in seconds. Used only when performing authoritative name server queries.",
|
2019-01-03 15:59:53 +00:00
|
|
|
Value: 10,
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.BoolFlag{
|
2018-12-06 21:50:17 +00:00
|
|
|
Name: "pem",
|
2023-03-02 18:29:29 +00:00
|
|
|
Usage: "Generate an additional .pem (base64) file by concatenating the .key and .crt files together.",
|
2018-12-06 21:50:17 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.BoolFlag{
|
2024-01-27 22:44:14 +00:00
|
|
|
Name: "pfx",
|
|
|
|
Usage: "Generate an additional .pfx (PKCS#12) file by concatenating the .key and .crt and issuer .crt files together.",
|
|
|
|
EnvVars: []string{"LEGO_PFX"},
|
2021-12-25 18:36:01 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.StringFlag{
|
2024-01-27 22:44:14 +00:00
|
|
|
Name: "pfx.pass",
|
|
|
|
Usage: "The password used to encrypt the .pfx (PCKS#12) file.",
|
|
|
|
Value: pkcs12.DefaultPassword,
|
|
|
|
EnvVars: []string{"LEGO_PFX_PASSWORD"},
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "pfx.format",
|
|
|
|
Usage: "The encoding format to use when encrypting the .pfx (PCKS#12) file. Supported: RC2, DES, SHA256.",
|
|
|
|
Value: "RC2",
|
|
|
|
EnvVars: []string{"LEGO_PFX_FORMAT"},
|
2021-12-25 18:36:01 +00:00
|
|
|
},
|
2022-02-13 11:28:51 +00:00
|
|
|
&cli.IntFlag{
|
2019-01-09 07:29:17 +00:00
|
|
|
Name: "cert.timeout",
|
|
|
|
Usage: "Set the certificate timeout value to a specific value in seconds. Only used when obtaining certificates.",
|
|
|
|
Value: 30,
|
|
|
|
},
|
2024-06-13 20:48:04 +00:00
|
|
|
&cli.IntFlag{
|
|
|
|
Name: "overall-request-limit",
|
|
|
|
Usage: "ACME overall requests limit.",
|
|
|
|
Value: certificate.DefaultOverallRequestLimit,
|
|
|
|
},
|
2022-06-29 18:56:56 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "user-agent",
|
|
|
|
Usage: "Add to the user-agent sent to the CA to identify an application embedding lego-cli",
|
|
|
|
},
|
2018-12-06 21:50:17 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-28 14:45:48 +00:00
|
|
|
|
|
|
|
func getTime(ctx *cli.Context, name string) time.Time {
|
|
|
|
value := ctx.Timestamp(name)
|
|
|
|
if value == nil {
|
|
|
|
return time.Time{}
|
|
|
|
}
|
|
|
|
return *value
|
|
|
|
}
|