From f9332035cbf491bd30d48ec9a606d63b81f80c45 Mon Sep 17 00:00:00 2001 From: Adam Bark Date: Fri, 24 Jul 2020 14:13:59 -0500 Subject: [PATCH 1/5] Add default configuration values Address issue #297 --- cmd/pebble/main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/pebble/main.go b/cmd/pebble/main.go index bb4bea4b..69ed42b1 100644 --- a/cmd/pebble/main.go +++ b/cmd/pebble/main.go @@ -29,6 +29,17 @@ type config struct { } } +func setConfigDefaults() (config) { + var conf config + conf.Pebble.ListenAddress = "0.0.0.0:14000" + conf.Pebble.ManagementListenAddress = "0.0.0.0:15000" + conf.Pebble.Certificate = "test/certs/localhost/cert.pem" + conf.Pebble.PrivateKey = "test/certs/localhost/key.pem" + conf.Pebble.HTTPPort = 5002 + conf.Pebble.TLSPort = 5001 + return conf +} + func main() { configFile := flag.String( "config", @@ -52,7 +63,7 @@ func main() { logger := log.New(os.Stdout, "Pebble ", log.LstdFlags) logger.Printf("Starting Pebble ACME server") - var c config + c := setConfigDefaults() err := cmd.ReadConfigFile(*configFile, &c) cmd.FailOnError(err, "Reading JSON config file into config structure") From 6bdc6f1a6b99ce26407ba570e63ac13243342239 Mon Sep 17 00:00:00 2001 From: Adam Bark Date: Mon, 27 Jul 2020 12:54:47 -0500 Subject: [PATCH 2/5] Apply configuration defaults from a file --- cmd/pebble/main.go | 20 +++++++++---------- ...pebble-config.json => default-config.json} | 0 2 files changed, 9 insertions(+), 11 deletions(-) rename test/config/{pebble-config.json => default-config.json} (100%) diff --git a/cmd/pebble/main.go b/cmd/pebble/main.go index 69ed42b1..4b195fd8 100644 --- a/cmd/pebble/main.go +++ b/cmd/pebble/main.go @@ -29,21 +29,19 @@ type config struct { } } -func setConfigDefaults() (config) { - var conf config - conf.Pebble.ListenAddress = "0.0.0.0:14000" - conf.Pebble.ManagementListenAddress = "0.0.0.0:15000" - conf.Pebble.Certificate = "test/certs/localhost/cert.pem" - conf.Pebble.PrivateKey = "test/certs/localhost/key.pem" - conf.Pebble.HTTPPort = 5002 - conf.Pebble.TLSPort = 5001 - return conf +const DefaultConfigPath = "test/config/default-config.json" + +func getDefaultConfig() (config) { + var c config + err := cmd.ReadConfigFile(DefaultConfigPath, &c) + cmd.FailOnError(err, "Reading default JSON config file into config structure") + return c } func main() { configFile := flag.String( "config", - "test/config/pebble-config.json", + DefaultConfigPath, "File path to the Pebble configuration file") strictMode := flag.Bool( "strict", @@ -63,7 +61,7 @@ func main() { logger := log.New(os.Stdout, "Pebble ", log.LstdFlags) logger.Printf("Starting Pebble ACME server") - c := setConfigDefaults() + c := getDefaultConfig() err := cmd.ReadConfigFile(*configFile, &c) cmd.FailOnError(err, "Reading JSON config file into config structure") diff --git a/test/config/pebble-config.json b/test/config/default-config.json similarity index 100% rename from test/config/pebble-config.json rename to test/config/default-config.json From 6f8381425a8a177a655dd8a239d6f6a150f8fcbe Mon Sep 17 00:00:00 2001 From: Adam Bark Date: Mon, 27 Jul 2020 16:10:06 -0500 Subject: [PATCH 3/5] Update cmd/pebble/main.go Co-authored-by: Aaron Gable --- cmd/pebble/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/pebble/main.go b/cmd/pebble/main.go index 4b195fd8..38c132b2 100644 --- a/cmd/pebble/main.go +++ b/cmd/pebble/main.go @@ -31,7 +31,7 @@ type config struct { const DefaultConfigPath = "test/config/default-config.json" -func getDefaultConfig() (config) { +func getDefaultConfig() config { var c config err := cmd.ReadConfigFile(DefaultConfigPath, &c) cmd.FailOnError(err, "Reading default JSON config file into config structure") From 193f076096a98a03bbfae36c15adb3c63405116d Mon Sep 17 00:00:00 2001 From: Adam Bark Date: Wed, 29 Jul 2020 14:17:56 -0500 Subject: [PATCH 4/5] Add check for default config existence If default config exists try to read it into the config structure else return a blank config. --- cmd/pebble/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/pebble/main.go b/cmd/pebble/main.go index 38c132b2..962e5213 100644 --- a/cmd/pebble/main.go +++ b/cmd/pebble/main.go @@ -33,8 +33,10 @@ const DefaultConfigPath = "test/config/default-config.json" func getDefaultConfig() config { var c config - err := cmd.ReadConfigFile(DefaultConfigPath, &c) - cmd.FailOnError(err, "Reading default JSON config file into config structure") + if _, err := os.Stat(DefaultConfigPath); err == nil { + err := cmd.ReadConfigFile(DefaultConfigPath, &c) + cmd.FailOnError(err, "Reading default JSON config file into config structure") + } return c } From 9590ec4407f750231b7d505250f819b02a900e5a Mon Sep 17 00:00:00 2001 From: Adam Bark Date: Fri, 31 Jul 2020 12:22:44 -0500 Subject: [PATCH 5/5] Update default config naming --- README.md | 10 +++++----- docker-compose.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9d5978c4..46857c2d 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ correctly. ### Binary ```bash -pebble -config ./test/config/pebble-config.json +pebble -config ./test/config/default-config.json ``` Afterwards you can access the Pebble server's ACME directory @@ -206,7 +206,7 @@ challenge to observe the state since the CA may send many validation requests. To test issuance "at full speed" with no artificial sleeps set the environment variable `PEBBLE_VA_NOSLEEP` to `1`. E.g. -`PEBBLE_VA_NOSLEEP=1 pebble -config ./test/config/pebble-config.json` +`PEBBLE_VA_NOSLEEP=1 pebble -config ./test/config/default-config.json` The maximal number of seconds to sleep can be configured by defining `PEBBLE_VA_SLEEPTIME`. It must be set to a positive integer. @@ -282,7 +282,7 @@ These endpoints are specific to Pebble and its internal behavior, and are not pa of the RFC 8555 that defines the ACME protocol. The management interface is configured by the `managementListenAddress` field in -`pebble-config.json` that defines the address and the port on which the management +`default-config.json` that defines the address and the port on which the management interface will listen on. Set `managementListenAddress` to an empty string or `null` to disable it. @@ -353,12 +353,12 @@ The endpoint returns the information as a JSON object: Pebble does not support the OCSP protocol as a responder and so does not set the OCSP Responder URL in the issued certificates. However, if you setup a proper OCSP Responder run side by side with Pebble, you may want to set this URL. -This is possible by setting the field `ocspResponderURL` of the `pebble-config.json` +This is possible by setting the field `ocspResponderURL` of the `default-config.json` consummed by Pebble to a non empty string: in this case, this string will be use in the appropriate field of all issued certificates. For instance, to have Pebble issue certificates that instruct a client to check the URL `http://127.0.0.1:4002` -to retrieve the OCSP status of a certificate, run Pebble with a `pebble-config.json` that includes: +to retrieve the OCSP status of a certificate, run Pebble with a `default-config.json` that includes: ``` "ocspResponderURL": "http://127.0.0.1:4002", diff --git a/docker-compose.yml b/docker-compose.yml index 96170349..199751bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: pebble: image: letsencrypt/pebble:latest - command: pebble -config /test/config/pebble-config.json -strict -dnsserver 10.30.50.3:8053 + command: pebble -config /test/config/default-config.json -strict -dnsserver 10.30.50.3:8053 environment: # TODO(@cpu): Delete this explicit GODEBUG env var once Pebble is built # with Go 1.13.x which defaults TLS 1.3 to on