Skip to content

AndroidMessageHandler doesn't use ClientCertificates #7274

Closed
@simonrozsival

Description

@simonrozsival

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.), Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 6.0

Description

A customer reported they can't use the ClientCertificates property of AndroidMessageHandler in their app (dotnet/runtime#73960). The ClientCertificates property is defined to match the API of System.Net.Http.HttpClientHandler, but it's never used.

Steps to Reproduce

The following code doesn't work:

var handler = new HttpClientHandler(); // assuming $(UseNativeHttpHandler)=true
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
// ClientCertificates is `null` even though the HttpClientHandler's property isn't annotated as nullable
handler.ClientCertificates.Add(certificate);

var client = new HttpClient(handler);
// if the server requires client certificate, this request will fail because the certificate we added was ignored
var result = await client.GetAsync("...");

Did you find any workaround?

Customers can extend AndroidMessageHandler and implement the functionality by overriding the ConfigureKeyStore method.

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: HTTPIssues with sockets / HttpClient.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions