Skip to content

pki: Handle error immediately after reading root from disk - #7896

Merged
francislavoie merged 1 commit into
caddyserver:masterfrom
hslatman:fix-root-cert-index-out-of-range
Jul 20, 2026
Merged

francislavoie merged 1 commit into
caddyserver:masterfrom
hslatman:fix-root-cert-index-out-of-range

Conversation

@hslatman

Copy link
Copy Markdown
Contributor

In #7057, the behavior of KeyPair.Load was changed to return a certificate chain. While the change was primarily meant for intermediates, it also affected how a root (or roots) were loaded. The existing error handling logic relied on a shared err != nil check, but with the new behavior there's no guarantee that there's actually a root in the PEM file on disk.

This commit handles the error immediately after reading the PEM from disk.

Fixes: #7895

In caddyserver#7057, the behavior
of `KeyPair.Load` was changed to return a certificate chain. While
the change was primarily meant for intermediates, it also affected
how a root (or roots) were loaded. The existing error handling
logic relied on a shared `err != nil` check, but with the new
behavior there's no guarantee that there's actually a root in
the PEM file on disk.

This commit handles the error immediately after reading the PEM
from disk.

Fixes: caddyserver#7895
@hslatman
hslatman force-pushed the fix-root-cert-index-out-of-range branch from dda95e8 to 984771a Compare July 19, 2026 20:33
@hslatman hslatman changed the title Handle error immediately after reading root from disk pki: Handle error immediately after reading root from disk Jul 19, 2026
@hslatman
hslatman marked this pull request as ready for review July 19, 2026 20:37
@francislavoie francislavoie added the bug 🐞 Something isn't working label Jul 20, 2026
@francislavoie francislavoie added this to the v2.11.5 milestone Jul 20, 2026
@francislavoie
francislavoie merged commit 9738f49 into caddyserver:master Jul 20, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants