Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpClientHandler ClientCertificate property is null on Android #8860

Closed
GarageGadget opened this issue Jul 20, 2022 · 3 comments
Closed

HttpClientHandler ClientCertificate property is null on Android #8860

GarageGadget opened this issue Jul 20, 2022 · 3 comments
Labels
partner/android Issues for the Android SDK platform/android 🤖 s/needs-attention Issue has more information and needs another look s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@GarageGadget
Copy link

GarageGadget commented Jul 20, 2022

Description

The application I am building requires the use of Client X509 certificates.
I am trying to add the client certificate to the HttpClientHandler, however the ClientCertificate property is null and therefore throwing an null reference exception when calling the Add() method with a X509 certificate.

Snippet

  var handler = new HttpClientHandler();
  handler.SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13;
  handler.ClientCertificateOptions = ClientCertificateOption.Manual;
  if(handler.ClientCertificates == null)
  {
      Console.WriteLine("ClientCertificates is null");
  }
  // handler.ClientCertificates.Add(clientCert); <-- Failure


Using
Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview
Version 17.3.0 Preview 4.0

Steps to Reproduce

  1. Create a Maui App
  2. Add code similar to snippet above in a button handler or any suitable method.
  3. Run and debug the Maui App on Android
  4. The ClientCertificates property will be null and log the message to the console.

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 9

Did you find any workaround?

No response

Relevant log output

No response

@GarageGadget GarageGadget added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jul 20, 2022
@rmarinho rmarinho added partner/android Issues for the Android SDK s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jul 20, 2022
@jonathanpeppers
Copy link
Member

jonathanpeppers commented Jul 20, 2022

@steveisok @simonrozsival would you know if this is expected behavior?

Should we initialize this property with an empty collection?

https://github.com/xamarin/xamarin-android/blob/ace5f71c40d05070612cb860f38764eae3deef59/src/Mono.Android/Xamarin.Android.Net/AndroidMessageHandler.cs#L150

@GarageGadget for now you can do this as a workaround?

handler.ClientCertificates ??= new ();

@jfversluis jfversluis added the s/needs-info Issue needs more info from the author label Aug 24, 2022
@ghost
Copy link

ghost commented Aug 24, 2022

Hi @GarageGadget. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@simonrozsival
Copy link
Member

We had a similar report from a different customer recently, here's the issue in Xamarin.Android: dotnet/android#7274

I suggest closing this issue as it's specific to Xamarin.Android.

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Aug 24, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
partner/android Issues for the Android SDK platform/android 🤖 s/needs-attention Issue has more information and needs another look s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants