Skip to content

Custom AndroidMessageHandler.ServerCertificateCustomValidationCallback that returns false may cause application crash while debugging. #8608

Open
@anton-yashin

Description

@anton-yashin

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

  1. Create new android app with code like this
    Sample code:
try
{
    using (var ch = new AndroidMessageHandler())
    {
        ch.ServerCertificateCustomValidationCallback += (a, b, c, d) => false;
        using (var hc = new HttpClient(ch))
        {
            var result = await hc.GetAsync("https://github.com");
            // never get here
        }
    }
}
catch (Exception ex)
{
    // may be get here
    XDebug.WriteLine($"exception handled {ex.Message}");
}
  1. Run it several times. Two times in my case.
  2. Observe application crash.
    See sample project in attachment: UnhandledCertificateException.zip

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: Mono.AndroidIssues with the Android API binding (Mono.Android.dll).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions