Bug 20316 - System.Security.Cryptography.CryptographicException: Unsupported hash algorithm: 11.2.840.113549.1.1.5
Summary: System.Security.Cryptography.CryptographicException: Unsupported hash algorit...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.14.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2014-06-03 14:49 UTC by mlpstingray
Modified: 2014-06-27 10:13 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description mlpstingray 2014-06-03 14:49:20 UTC
I was trying to create a test-bed which reproduce the following bug https://bugzilla.xamarin.com/show_bug.cgi?id=20165

I encounter this other bug with the following stack trace :

ERROR building certificate chain: System.ArgumentException: certificate ---> System.Security.Cryptography.CryptographicException: Unsupported hash algorithm: 11.2.840.113549.1.1.5
05-30 23:55:07.695 I/mono-stderr(29100): ERROR building certificate chain: System.ArgumentException: certificate ---> System.Security.Cryptography.CryptographicException: Unsupported hash algorithm: 11.2.840.113549.1.1.5
  at Mono.Security.Cryptography.PKCS1.HashNameFromOid (System.String oid, Boolean throwOnError) [0x00000] in <filename unknown>:0 
  at Mono.Security.X509.X509Certificate.VerifySignature (System.Security.Cryptography.RSA rsa) [0x00000] in <filename unknown>:0 
05-30 23:55:07.695 I/mono-stderr(29100):   at Mono.Security.Cryptography.PKCS1.HashNameFromOid (System.String oid, Boolean throwOnError) [0x00000] in <filename unknown>:0 
  at Mono.Security.X509.X509Certificate.VerifySignature (System.Security.Cryptography.AsymmetricAlgorithm aa) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.IsSignedWith (System.Security.Cryptography.X509Certificates.X509Certificate2 signed, System.Security.Cryptography.AsymmetricAlgorithm pubkey) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.Process (Int32 n) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.ValidateChain (X509ChainStatusFlags flag) [0x00000] in <filename unknown>:0 
05-30 23:55:07.695 I/mono-stderr(29100):   at Mono.Security.X509.X509Certificate.VerifySignature (System.Security.Cryptography.RSA rsa) [0x00000] in <filename unknown>:0 
05-30 23:55:07.695 I/mono-stderr(29100):   at Mono.Security.X509.X509Certificate.VerifySignature (System.Security.Cryptography.AsymmetricAlgorithm aa) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
05-30 23:55:07.695 I/mono-stderr(29100):   at System.Security.Cryptography.X509Certificates.X509Chain.IsSignedWith (System.Security.Cryptography.X509Certificates.X509Certificate2 signed, System.Security.Cryptography.AsymmetricAlgorithm pubkey) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in <filename unknown>:0 
05-30 23:55:07.695 I/mono-stderr(29100):   at System.Security.Cryptography.X509Certificates.X509Chain.Process (Int32 n) [0x00000] in <filename unknown>:0 
Please, report this problem to the Mono team
05-30 23:55:07.695 I/mono-stderr(29100):   at System.Security.Cryptography.X509Certificates.X509Chain.ValidateChain (X509ChainStatusFlags flag) [0x00000] in <filename unknown>:0 
05-30 23:55:07.695 I/mono-stderr(29100):   at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
05-30 23:55:07.700 I/mono-stderr(29100):   --- End of inner exception stack trace ---
05-30 23:55:07.700 I/mono-stderr(29100):   at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
05-30 23:55:07.700 I/mono-stderr(29100):   at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection certs) [0x00000] in <filename unknown>:0 
05-30 23:55:07.700 I/mono-stderr(29100): Please, report this problem to the Mono team

Not sure how relevant it is since I am not using the WebClient in a normal usage, but still it says that I should report the problem.

I will add the Test-Bed project in private since I had to export a part of our code in the project.
Comment 2 Sadik Ali 2014-06-04 08:59:23 UTC
I have tried to reproduce this issue with attached sample but I am unable to reproduce this issue.

I have deployed the attached sample on device/emulator and it doesn't throw any " System.Security.Cryptography.CryptographicException" exception.

Screencast: http://www.screencast.com/t/RietlQ8IoEA

Could you please provide your full xamarin studio version(on XS click on Help=> About => Show details => Copy Information)?

Environment Info

Windows 6.1.7601.65536 (64-bit)
Xamarin Studio: 5.0 (build 878)
Xamarin.Android: 4.12.3

Build Information
Release ID: 500000878
Git revision: bcd66920d963483e7d638a2339c4022fe035b529a
Build date: 2014-05-27 17:40:17-04a
Xamarin addins: da9064ce55b0fa90930a7c437a4cc1ae0e5c778ca
Comment 3 mlpstingray 2014-06-04 09:10:41 UTC
I forgot to mention the details, I am running the test on :

Microsoft Visual Studio Professional 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.50938
Xamarin 3.0.54.0
Xamarin Android 4.12.4.20

Running on a Android device Galaxy S3 on Android 4.1.2

It occurs pretty early, 20-30 seconds and you should see the issue in the Logcat. If this isn't the case, we probably don't have the same configuration.
Comment 4 Sadik Ali 2014-06-05 07:23:47 UTC
@mlpstingray:

Thanks for the environment details.

I have again tried to reproduce this issue many times with attached project on different devices(Galaxy S3 on Android 4.1.2, Samaung S5 kit-kat) with following builds but still I am unable to reproduce this issue.

I can't reproduce this, we may have to see if a developer can figure out what's going on from the logs. If you have a chance, it might also be helpful to include full device logs(open cmd=>navigate to "AndroidSDK\platform-tools" => type adb logcat). 

Screencast: http://screencast.com/t/wm8t8cbJPq

logcat output: https://gist.github.com/AkhileshKumar01/0c6ca36e2122488bcdc5

Environment Info:

Windows 7
Microsoft Visual Studio Professional 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Xamarin   3.0.54.0 (d3cf238e3845e930e312b6ec9b4c6c5437c33067)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android

Xamarin.Android   4.12.4.20 (b5dc5ce91305e19de51d71a1122c109719c4bc34)
Visual Studio plugin to enable development for Xamarin.Android.
Comment 5 mlpstingray 2014-06-05 14:32:00 UTC
The only remaining difference might be that I am running the sample in debug while keeping the device plugged to the USB cable, so I can see this error appear in the logcat/Output of Visual Studio in debug mode.
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-17 23:16:14 UTC
Hi,

I was working on a case that started off with a different exception message, but ended up with a test app that also produced this "Unsupported hash algorithm" error message. (Bug #20677)

Long story short, it looks like the problem might be fixed in the current alpha channel version:
Xamarin 3.1.198


If you like, you can test the alpha channel version to see if it resolves the problem for you. As you very likely already know, if you do try this, it would probably be best to switch back to the stable channel before building any apps for publication. The alpha channel is only only very lightly tested by QA.


I also tried running the test app attached to this case, but it didn't produce the error on my phone.
Comment 7 mlpstingray 2014-06-18 09:06:44 UTC
Hello,

I tried Alpha version yesterday, but I end up rolling back because I had too much problems fixing every references that has changed, since I just wanted to test if the issue for bug https://bugzilla.xamarin.com/show_bug.cgi?id=20165 was fixed for us and we are releasing in 7-8 days. 

I will eventually try this one too, but since I cannot see the Bug #20677, it seems private to me, I doubt that this one has been fixed along the other ones.

I also notice after entering the bug, that it seems to be a recurring issues and a similar stack trace has been reported before : https://bugzilla.xamarin.com/show_bug.cgi?id=7539

Plus some other that seems to be in the same field: 

https://bugzilla.xamarin.com/show_bug.cgi?id=8788
https://bugzilla.xamarin.com/show_bug.cgi?id=8715

I'll test it when the next version becomes stable. In the meantime, keep me up-to-date if anything happen. 

Regards
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-18 10:56:00 UTC
Whoops. Sorry about that. Typo in the bug number. The one I just filed should be bug #20667.

In any case, thanks for the update about testing the alpha channel! Hopefully once those changes make their way to beta and stable, they'll solve the problem.

As for bug 20165, that one should be fixed in the current _beta_ channel version (Xamarin 3.0.56). That release is much more similar to the stable channel release, so it shouldn't cause as many breakages as the alpha channel (hopefully zero).


Good idea to point out those other bugs [1, 2, 3] with the same error message. The key difference in those old bugs is that the hash algorithm value is a "real," correct number, rather than a corrupted one:

1.2.840.113549.1.1.11
"sha256WithRSAEncryption"


[1] https://bugzilla.xamarin.com/show_bug.cgi?id=7539
[2] https://bugzilla.xamarin.com/show_bug.cgi?id=8715
[3] https://bugzilla.xamarin.com/show_bug.cgi?id=8788

I think these older bug reports simply predate Mono support [4, 5] for that particular algorithm. I suspect all of those bugs are resolved as of Xamarin.Android 4.8.0.

[4] https://bugzilla.xamarin.com/show_bug.cgi?id=12303#c1
[5] https://bugzilla.xamarin.com/show_bug.cgi?id=8788#c5
Comment 9 mlpstingray 2014-06-27 10:13:40 UTC
I am now on the latest Xamarin android version and this doesn't seems to happen anymore. I guess it was a bug introduced in 3.0 which has been resolved by now.

Thanks for your time anyway.