Use certificate_chain_file for intermediate cert support - #3
Merged
Merged
Conversation
SSL_CTX_use_certificate_file only loads a single certificate. Switch to SSL_CTX_use_certificate_chain_file so intermediate certificates in the PEM file are preserved during the TLS handshake.
There was a problem hiding this comment.
Build & Tests
Build: pass — type-checks clean, CI green on macOS and Ubuntu.
Tests: pass — all tests pass, including the server certificate loading tests (self-signed cert/key generation, TlsServerCtx.create with valid and invalid paths, loopback TLS echo, end-to-end accept test).
Findings
No issues.
Verified:
- Return semantics preserved: Both
SSL_CTX_use_certificate_fileandSSL_CTX_use_certificate_chain_filereturn<= 0on error, so the existing error check at line 335 remains correct. SSL_FILETYPE_PEMremoval correct:SSL_CTX_use_certificate_chain_fileonly supports PEM format and does not take a format parameter — the removal is required by the API signature.- Client-side not affected: The client context (
carp_tls_get_client_ctx, lines 42-58) does not load certificates; it only configures verification. No corresponding change needed. - Test helpers: The inline server in
test/test_helpers.h:167still usesSSL_CTX_use_certificate_file— this is fine, it's a standalone echo server in a child process, not the main code path. - No CHANGELOG exists in the repo, so nothing to update.
The change is well-motivated: SSL_CTX_use_certificate_chain_file preserves intermediate certificates in the PEM file during the TLS handshake, which SSL_CTX_use_certificate_file does not. This matters for real-world deployments using certificate chains.
Verdict: merge
Correct one-line change with clear benefit, green CI, comprehensive test coverage of the affected path. Clean to merge.
hellerve
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SSL_CTX_use_certificate_filetoSSL_CTX_use_certificate_chain_fileinTlsServerCtx_create_so intermediate certificates in the PEM file are preserved during the TLS handshake.This is the one useful change extracted from #2, which was otherwise churn.
Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.