summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIan <ViViDboarder@gmail.com>2020-11-23 12:03:58 -0800
committerGitHub <noreply@github.com>2020-11-23 13:03:58 -0700
commit06ba006f9bb7fe4fe8fb97bbda594f3c438cb6ad (patch)
tree0f570f9f4eb89b03c5a91441c5b74bd0ae59a172 /modules
parentc6dec305357868ec9ba7fbc45e6cb70404cc23a6 (diff)
acme_server: switch to bbolt storage (#3868)
* acme_server: switch to bbolt storage There have been some issues with the badger storage engine being used by the embedded acme_server. This will replace the storage engine with bbolt * Switch database path back to acme_server/db and remove if directory
Diffstat (limited to 'modules')
-rw-r--r--modules/caddypki/acmeserver/acmeserver.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/modules/caddypki/acmeserver/acmeserver.go b/modules/caddypki/acmeserver/acmeserver.go
index 9d8a6fc..5c9f74b 100644
--- a/modules/caddypki/acmeserver/acmeserver.go
+++ b/modules/caddypki/acmeserver/acmeserver.go
@@ -32,6 +32,7 @@ import (
"github.com/smallstep/certificates/authority/provisioner"
"github.com/smallstep/certificates/db"
"github.com/smallstep/nosql"
+ "go.uber.org/zap"
)
func init() {
@@ -77,6 +78,7 @@ func (Handler) CaddyModule() caddy.ModuleInfo {
// Provision sets up the ACME server handler.
func (ash *Handler) Provision(ctx caddy.Context) error {
+ logger := ctx.Logger(ash)
// set some defaults
if ash.CA == "" {
ash.CA = caddypki.DefaultCAID
@@ -99,7 +101,8 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
return fmt.Errorf("no certificate authority configured with id: %s", ash.CA)
}
- dbFolder := filepath.Join(caddy.AppDataDir(), "acme_server", "db")
+ dbFolder := filepath.Join(caddy.AppDataDir(), "acme_server")
+ dbPath := filepath.Join(dbFolder, "db")
// TODO: See https://github.com/smallstep/nosql/issues/7
err = os.MkdirAll(dbFolder, 0755)
@@ -107,6 +110,18 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
return fmt.Errorf("making folder for ACME server database: %v", err)
}
+ // Check to see if previous db exists
+ var stat os.FileInfo
+ stat, err = os.Stat(dbPath)
+ if stat != nil && err == nil {
+ // A badger db is found and should be removed
+ if stat.IsDir() {
+ logger.Warn("Found an old badger database and removing it",
+ zap.String("path", dbPath))
+ _ = os.RemoveAll(dbPath)
+ }
+ }
+
authorityConfig := caddypki.AuthorityConfig{
AuthConfig: &authority.AuthConfig{
Provisioners: provisioner.List{
@@ -122,8 +137,8 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
},
},
DB: &db.Config{
- Type: "badger",
- DataSource: dbFolder,
+ Type: "bbolt",
+ DataSource: dbPath,
},
}