[release/9.0.1xx] [Foundation] Treat any exception during X509Chain.Build as a remote certificate chain error. Fixes #24739.#24758
Conversation
…ertificate chain error. Fixes #24739. In iOS 26.4 beta 4, X509Chain.Build started throwing CryptographicException: ``` System.Security.Cryptography.Interop+AppleCrypto+AppleCommonCryptoCryptographicException: Unable to decode the provided data. at System.Security.Cryptography.X509Certificates.SecTrustChainPal.Execute(:0) at System.Security.Cryptography.X509Certificates.ChainPal.BuildChain(:0) at System.Security.Cryptography.X509Certificates.X509Chain.Build(:0) at Foundation.NSUrlSessionHandler+ServerCertificateCustomValidationCallbackHelper.EvaluateSslPolicyErrors(:0) at Foundation.NSUrlSessionHandler+ServerCertificateCustomValidationCallbackHelper.Invoke(:0) at Foundation.NSUrlSessionHandler.TryInvokeServerCertificateCustomValidationCallback(:0) at Foundation.NSUrlSessionHandler+NSUrlSessionHandlerDelegate.DidReceiveChallengeImpl(:0) at Foundation.NSUrlSessionHandler+NSUrlSessionHandlerDelegate.DidReceiveChallenge(:0) at InvokeStub_NSUrlSessionHandlerDelegate.DidReceiveChallenge(:0) ``` The underlying cause of these exceptions is handled in this issue: dotnet/runtime#124552, this change is only dealing with the fact that the process crashes when an unexpected exception occurs in this code path in NSUrlSessionHandler. The fix is to handle all exceptions in the call X509Chain.Build, and report them as a certificate chain error in the custom server validation callback; then the app developer can handle them as they see fit. Fixes #24739. See also: * dotnet/runtime#124552
There was a problem hiding this comment.
Pull request overview
Backport to the release/9.0.1xx branch to prevent process crashes when X509Chain.Build throws unexpectedly during TLS server certificate evaluation in NSUrlSessionHandler, so the app’s custom validation callback can still run and decide how to handle the failure.
Changes:
- Broaden exception handling around
X509Chain.Buildto treat any thrown exception asSslPolicyErrors.RemoteCertificateChainErrors.
✅ [CI Build #e40523e] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #e40523e] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #e40523e] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
💻 [CI Build #e40523e] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #e40523e] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #e40523e] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #e40523e] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #e40523e] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #e40523e] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 115 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download Pipeline on Agent |
In iOS 26.4 beta 4, X509Chain.Build started throwing CryptographicException:
The underlying cause of these exceptions is handled in this issue:
dotnet/runtime#124552, this change is only
dealing with the fact that the process crashes when an unexpected
exception occurs in this code path in NSUrlSessionHandler.
The fix is to handle all exceptions in the call X509Chain.Build, and
report them as a certificate chain error in the custom server validation
callback; then the app developer can handle them as they see fit.
Fixes #24739.
See also:
Backport of #24754.