feat(destination): apply client certificates to DestinationHttpClient - #278
Open
jplbrun wants to merge 3 commits into
Open
feat(destination): apply client certificates to DestinationHttpClient#278jplbrun wants to merge 3 commits into
jplbrun wants to merge 3 commits into
Conversation
jplbrun
marked this pull request as ready for review
August 20, 2026 16:47
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.
Description
DestinationHttpClientdid not configure client certificates for destinations usingClientCertificateAuthentication, even when the destination carried the certificate material — outbound mTLS calls failed with HTTP 401.This PR makes
DestinationHttpClientapply the client certificate automatically. When a destination'sAuthenticationisClientCertificateAuthentication, it builds a verifying SSL context from the destination's certificate list and mounts it on the session'shttps://adapter. No caller code changes are required.New
_cert_loader.py—build_client_cert_context(destination)returns a verifyingssl.SSLContext, orNonewhen the destination does not use client-cert auth. Certificate material is written to a short-lived, owner-only (0o600) temp file, loaded viaload_cert_chain, then deleted immediately._destination_http_client.py— a_ClientCertAdapter(requestsHTTPAdaptersubclass) injects the context into the pool and proxy managers.New public
DestinationCertificateError.Supported formats: PEM (
.pem) and PKCS12 (.p12/.pfx), withKeyStorePasswordfor encrypted keys andKeyStoreLocationto select a specific certificate.DestinationHttpClientalso gains context-manager support (with ... as http:), which closes the underlying session on exit.Related Issue
Closes #254
Type of Change
Please check the relevant option:
How to Test
Step 1 — Generate test certificates locally:
Step 2 — Upload certificates to BTP Cockpit (Connectivity → Destination Certificates → Create → Import):
combined_enc.pemcombined_enc.pemclient.p12client.p12client.pfxclient.pfxStep 3 — Create destinations on BTP (Connectivity → Destinations → Import):
destination-pem.json:{ "destination": { "Authentication": "ClientCertificateAuthentication", "KeyStore.Source": "DestinationService", "KeyStoreLocation": "combined_enc.pem", "KeyStorePassword": "certpassword", "Name": "TEST_MTLS_PEM", "ProxyType": "Internet", "Type": "HTTP", "URL": "https://google.com" } }destination-p12.json:{ "destination": { "Authentication": "ClientCertificateAuthentication", "KeyStore.Source": "DestinationService", "KeyStoreLocation": "client.p12", "KeyStorePassword": "testpassword", "Name": "TEST_MTLS_P12", "ProxyType": "Internet", "Type": "HTTP", "URL": "https://google.com" } }destination-pfx.json:{ "destination": { "Authentication": "ClientCertificateAuthentication", "KeyStore.Source": "DestinationService", "KeyStoreLocation": "client.pfx", "KeyStorePassword": "testpassword", "Name": "TEST_MTLS_PFX", "ProxyType": "Internet", "Type": "HTTP", "URL": "https://google.com" } }Step 4 — Fetch each destination via the v2 API and create a
DestinationHttpClientfrom it. Confirm that a request to the destination URL succeeds.Checklist
Before submitting your PR, please review and check the following:
Breaking Changes
None. The constructor and
request()signatures ofDestinationHttpClientare unchanged. mTLS wiring is additive and only triggers forClientCertificateAuthenticationdestinations.Additional Notes
N/A