caddyserver/caddy · error

creating storage configuration: %v

Error message

creating storage configuration: %v

What it means

Returned by CA.Provision when the loaded storage module's CertMagicStorage() conversion fails — i.e. the module was found and instantiated, but it either does not properly implement caddy.StorageConverter or its own conversion to a certmagic.Storage returned an error. This sits between module loading (previous error) and storage use: the module exists but cannot produce a usable storage backend for this CA.

Source

Thrown at modules/caddypki/ca.go:118

	ca.mu = new(sync.RWMutex)
	ca.log = log.Named("ca." + id)
	ca.ctx = ctx

	if id == "" {
		return fmt.Errorf("CA ID is required (use 'local' for the default CA)")
	}
	ca.mu.Lock()
	ca.ID = id
	ca.mu.Unlock()

	if ca.StorageRaw != nil {
		val, err := ctx.LoadModule(ca, "StorageRaw")
		if err != nil {
			return fmt.Errorf("loading storage module: %v", err)
		}
		cmStorage, err := val.(caddy.StorageConverter).CertMagicStorage()
		if err != nil {
			return fmt.Errorf("creating storage configuration: %v", err)
		}
		ca.storage = cmStorage
	}
	if ca.storage == nil {
		ca.storage = ctx.Storage()
	}

	if ca.Name == "" {
		ca.Name = defaultCAName
	}
	if ca.RootCommonName == "" {
		ca.RootCommonName = defaultRootCommonName
	}
	if ca.IntermediateCommonName == "" {
		ca.IntermediateCommonName = defaultIntermediateCommonName
	}
	if ca.IntermediateLifetime == 0 {
		ca.IntermediateLifetime = caddy.Duration(defaultIntermediateLifetime)

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Read the wrapped error — plugins usually name the missing/invalid option
  2. Fill in required storage module options (address, credentials, bucket, etc.) and re-validate the config
  3. Rebuild with plugin versions matching your Caddy version (xcaddy build --with plugin@commit compatible with your Caddy release)
  4. Test the storage module globally first (global storage option) to isolate CA-specific config issues

Example fix

# before
"pki": { "certificate_authorities": { "local": {
  "storage": { "module": "redis" }
}}}

# after
"pki": { "certificate_authorities": { "local": {
  "storage": { "module": "redis", "address": "redis:6379", "password": "{env.REDIS_PASS}" }
}}}
Defensive patterns

Strategy: validation

Validate before calling

// Exercise the module's conversion early with the same options:
if sc, ok := loaded.(caddy.StorageConverter); ok {
    if _, err := sc.CertMagicStorage(); err != nil {
        return fmt.Errorf("storage module config invalid: %w", err)
    }
}

Type guard

func isStorageConverter(v any) (caddy.StorageConverter, bool) {
    sc, ok := v.(caddy.StorageConverter)
    return sc, ok
}

Try / catch

if err := ca.Provision(ctx, id, log); err != nil {
    if strings.Contains(err.Error(), "creating storage configuration") {
        return fmt.Errorf("check storage module options/credentials: %v", err)
    }
}

Prevention

When it happens

Trigger: A storage plugin whose CertMagicStorage() returns an error — invalid connection options (bad URL, missing credentials), unsupported configuration keys, or a plugin version whose conversion signature/behavior is incompatible with the Caddy version in use. The %v wraps the conversion error.

Common situations: Plugin version skew after upgrading Caddy (plugin compiled against an older certmagic); storage module config with missing required options (e.g. redis without an address); secrets provided as env vars that are empty at provisioning time; a third-party module that lazily validates only during conversion.

Related errors


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/dc2fe23947b6aefc. Report an issue: GitHub.