Skip to content

Caddy 2.11.4 - index out of range panic when loading root ca cert fails #7895

Closed

Description

@etinquis

Issue Details

I set up a pki server, something like this:

pki {
  ca my_ca {
    root {
      format pem_file
      cert my-ca.pem
    }
    intermediate {
      format pem_file
      cert my-intermediate-ca.pem
      key my-intermediate-ca.key
    }
  }
}

My root ca.pem is currently failing to load (for a reason yet unknown, afaik 2.11.2 worked and I skipped 2.11.3 due to mtls issue), triggering an index out of range panic:

Jul 19 18:46:59 pki systemd[1]: Starting Caddy...
Jul 19 18:46:59 pki systemd[1]: Started Caddy.
Jul 19 18:46:59 pki caddy[589]: panic: runtime error: index out of range [0] with length 0
Jul 19 18:46:59 pki caddy[589]: goroutine 1 [running]:
Jul 19 18:46:59 pki caddy[589]: github.com/caddyserver/caddy/v2/modules/caddypki.(*CA).Provision(0x1b35fea22160, {{0x2082de8, 0x1b35fe800640}, 0x1b35fe792210, 0x1b35fea12480, {0x1b35fe66be70, 0x1, 0x1}, {0x0, 0x0, ...}, ...}, ...)
Jul 19 18:46:59 pki caddy[589]:         github.com/caddyserver/caddy/v2/modules/caddypki/ca.go:155 +0xb7f

It appears that the load error is not checked before the array access https://github.com/caddyserver/caddy/blob/v2.11.4/modules/caddypki/ca.go#L155.

Assistance Disclosure

AI not used

If AI was used, describe the extent to which it was used.

No response

Activity

  1. etinquis commented on Jul 19, 2026

    @etinquis
    Author

    2.11.2 behavior is the same with the same cert, so disregard that note.

  2. etinquis commented on Jul 19, 2026

    @etinquis
    Author

    Root cause of the load failure was borked filesystem permissions on my end, so no new issue with respect to the certificate load itself.

  3. added a commit that references this issue on Jul 19, 2026
    984771a
  4. hslatman commented on Jul 19, 2026

    @hslatman
    Contributor

    I've opened #7896 for this.

  5. added a commit that references this issue on Jul 20, 2026
    9738f49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions