-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
dotnet/android
#8961Description
Description
Hello,
When I try to add a credential in ClientCredentials, its throws a NullReferenceException although, the code i wrote is quite simple
try
{
Stream stream = await FileSystem.OpenAppPackageFileAsync("d.cer");
using MemoryStream s = new();
stream.CopyTo(s);
stream.Dispose();
X509Certificate2 cert = new X509Certificate2(s.ToArray(), "PASSWORD");
SocketsHttpHandler shh = new()
{
UseCookies = true,
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
SslOptions =
{
EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12,
LocalCertificateSelectionCallback = (a,b,c,d,e) => c[0],
RemoteCertificateValidationCallback = (a,b,c,d) => true,
}
};
shh.SslOptions.ClientCertificates.Add(cert);
HttpClient c = new(shh);
var x = await c.GetAsync(new Uri("URL"));
_ = 1;
}
catch (Exception e)
{
_ = e;
}Its throw on the shh.SslOptions.ClientCertificates.Add(cert);
The certificate itself has a sha256 algoritm with its public key as RSA 2048 Bits
I also tried to use the network_security_config.xml from android and it crashed when i put the CA and pin
Steps to Reproduce
- Run the example that i wrote on the description
- Put it somewhere in the code, like a button
- Click it 🐞
Link to public reproduction project repository
https://github.com/taz4270/ExampleCert.App
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android
Affected platform versions
Android 13, iOS 16
Did you find any workaround?
No response
Relevant log output
No response