caddyserver/caddy · error

accessing certificate file

Error message

accessing certificate file: %v

What it means

cmdUntrust wraps the os.Stat failure for the file passed via --cert: the certificate file could not be accessed (missing path, permissions, or not a file), so it cannot be sanity-checked before truststore.UninstallFile is called. The command aborts with exit code failed-startup.

Solutions

  1. Check that the certificate file path exists and is readable.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at modules/caddypki/command.go:162 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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

Appendix: source

Thrown at modules/caddypki/command.go:162

}

func cmdUntrust(fl caddycmd.Flags) (int, error) {
	certFile := fl.String("cert")
	caID := fl.String("ca")
	addrFlag := fl.String("address")
	configFlag := fl.String("config")
	configAdapterFlag := fl.String("adapter")

	if certFile != "" && (caID != "" || addrFlag != "" || configFlag != "") {
		return caddy.ExitCodeFailedStartup, fmt.Errorf("conflicting command line arguments, cannot use --cert with other flags")
	}

	// If a file was specified, try to uninstall the cert matching that file
	if certFile != "" {
		// Sanity check, make sure cert file exists first
		_, err := os.Stat(certFile)
		if err != nil {
			return caddy.ExitCodeFailedStartup, fmt.Errorf("accessing certificate file: %v", err)
		}

		// Uninstall the file!
		err = truststore.UninstallFile(certFile,
			truststore.WithDebug(),
			truststore.WithFirefox(),
			truststore.WithJava())
		if err != nil {
			return caddy.ExitCodeFailedStartup, fmt.Errorf("failed to uninstall certificate file: %v", err)
		}

		return caddy.ExitCodeSuccess, nil
	}

	// Prepare the URI to the admin endpoint
	if caID == "" {
		caID = DefaultCAID
	}

View on GitHub (pinned to 50e54ee279)