WIF on Windows Server 2003
I was setting up Windows Identity Foundation (WIF, formerly known as Geneva) on Windows Server 2003 to reproduce a customer’s problem.
However, I got the following exception, even when trying one of the WIF SDK samples:
System.Security.Cryptography.X509Certificates.X509Utils._GetAlgIdFromOid(String oid) +0
System.Security.Cryptography.X509Certificates.X509Utils.OidToAlgId(String oid) +37
System.Security.Cryptography.RSACryptoServiceProvider.SignHash(Byte rgbHash, String str) +61
System.Security.Cryptography.RSAPKCS1SignatureFormatter.CreateSignature(Byte rgbHash) +105
System.Security.Cryptography.AsymmetricSignatureFormatter.CreateSignature(HashAlgorithm hash) +48
This was the first time I saw this exception, and I haven’t found any previous reports from customers on this in our internal knowledgebase (most likely due to WIF being a quite new product). Fortunately, binging around brought me quickly to a thread on http://social.msdn.microsoft.com/Forums/en-US/Geneva/thread/35c10fe5-9693-4f3a-9c5c-8afbb423ee95.
Phil Bolduc and Brent Schmaltz have found the cause for this issue. The encryption algorithm used by Geneva is not registered correctly on Windows Server 2003 for use by the .NET Framework. Indeed, the following steps resolved the issue:
1. Download Security.Cryptography.dll (either the binary of the source) from http://clrsecurity.codeplex.com/
2. Create a console application that references this Security.Cryptography.dll
3. Add the code below and execute the console application:
static void Main(string args)
Note that on an x64 OS, you need to create a 32-bit executable to register this for 32-bit processes.
Successful registration will create the following keys, respectively:
These contain the 3 OIDs, which represent the 3 new SHA2 algorithms:
· SHA256 - "2.16.8126.96.36.199.4.2.1!1"
· SHA384 - "2.16.8188.8.131.52.4.2.2!1"
· SHA512 - "2.16.8184.108.40.206.4.2.3!1"
As far as I can see, the issue is present on .NET 4.0 RTM as well.