Repository navigation
Custom AndroidMessageHandler.ServerCertificateCustomValidationCallback that returns false may cause application crash while debugging. #8608
Description
Activity
- addedArea: App RuntimeIssues in `libmonodroid.so`.Issues in `libmonodroid.so`.needs-triageIssues that need to be assigned.Issues that need to be assigned.
on Dec 22, 2023 You may run sample code more than one time to crash application. Debugger is required.
To be clear, the issue is that the exception isn't caught, correct?
The exception is expected, but the
catchhandler isn't functioning.With VS2022 17.8.3 debugger it's going to crash application, after second time running sample code. Without debugger seems works fine. There something strange happens.
With a debugger, it looks like a crash from an uncaught exception.
- changed the title
[-]Java.Security.Cert.CertificateException when AndroidMessageHandler.ServerCertificateCustomValidationCallback is set and returns false.[/-][+]Custom AndroidMessageHandler.ServerCertificateCustomValidationCallback that returns false may cause application crash while debugging.[/+]on Dec 23, 2023 Please provide more information about the crash. We would need the following:
Any messages VS shows in either its output/debug/etc panes and screenshots of popup boxes (if any) it produces.
Full logcat of the application from the device/emulator. To record it, please follow the steps below:
- Open the VS Developer prompt. Do not start the application yet.
- Type the following commands one by one:
adb shell setprop debug.mono.log default,assembly,mono_log_level=debug,mono_log_mask=alladb logcat -G 16Madb logcat -c
- Start the application from within VS and trigger the crash
- Back in the VS Developer prompt type:
adb logcat -d > logcat.txt
Please attach
logcat.txtand the requested VS messages/screenshots. Thanks!- addedneed-infoIssues that need more information from the author.Issues that need more information from the author.Area: Mono RuntimeMono-related issues: BCL bugs, AOT issues, etc.Mono-related issues: BCL bugs, AOT issues, etc.Area: DebuggerIssues using or interacting with the debugger.Issues using or interacting with the debugger.and removedArea: App RuntimeIssues in `libmonodroid.so`.Issues in `libmonodroid.so`.needs-triageIssues that need to be assigned.Issues that need to be assigned.
on Jan 3, 2024 Here requested addtional info
logcat.txt14 remaining items
My team seems to be running into this. Are there any other related tickets open?
We are just getting organized to look into this. Is there anything we could do to help move things along?
This can't be easily fixed without additional runtime support.
Would it be possible to raise the Java exception directly through some JNI helper in
ServerCertificateCustomValidatorwithout throwing it in C# first? Would we be able to avoid hitting the uncaught exception handler code?- added a commit that references this issue
on Dec 4, 2024 - added a commit that references this issue
on Jul 1, 2026 - added a commit that references this issue
on Jul 1, 2026 - added a commit that references this issue
on Jul 6, 2026 - addedpossibly-staleIssues that are potentially no longer relevant.Issues that are potentially no longer relevant.
on Aug 13, 2026 Checked w 36.1.69/10.0.100. Works fine. Thanks :)
Reacted by Šimon Rozsíval- addedneed-attentionA xamarin-android contributor needs to reviewA xamarin-android contributor needs to reviewand removedpossibly-staleIssues that are potentially no longer relevant.Issues that are potentially no longer relevant.
on Aug 14, 2026 - locked and limited conversation to collaborators
on Sep 14, 2026
Android application type
.NET Android (net7.0-android, net8.0-android, etc.)
Affected platform version
VS2022 18.3 with .net 34.0.43/8.0.100
Description
When you using AndroidMessageHandler with ServerCertificateCustomValidationCallback that returns false while debugging you may get application crash.
Steps to Reproduce
Sample code:
See sample project in attachment: UnhandledCertificateException.zip
Did you find any workaround?
No response
Relevant log output
No response