An aborted process that reads from a smartcard causes a 2nd reader process to hang

Hi all,     I’m currently working on the following issue on Windows Vista SP2 and Windows 7 RTM which doesn’t happen on Windows XP SP3: if a process that reads from a smart card is aborted unexpectedly after a call to SCardBeginTransaction without calling SCardEndTransaction, other instances of the same application or any other application using…

0

More on .NET CMS classes and SHA-2 algorithms

Hi all,   We don’t officially support the .NET CMS classes with SHA-2 algorithms. This won’t work on Vista and later with third-party CSPs, for instance: “An internal error ocurred” when using SHA-2 algorithms with SignedCMS “Invalid provider type specified” when using CNG providers with .NET CMS classes   But it will work on Vista…

0

How to call CryptMsg API in streaming mode – LargeCMS full sample

Hi all Some time ago I posted a sample which shows how to sign large CMS data by calling CryptMsg API directly (How to call CryptMsg API in streaming mode (C#)) and that way overcome the current limitations of SignedCms in .NET (“ASN1 value too large” error when calling SignedCms.ComputeSignature). I continued working on the…

4

Big delay while calling EnvelopedCms constructor

Hi all,   You may experience a big delay when calling EnvelopedCms constructor in your .NET application if you have networking problems. For example, if DNS server is not available, a call to the constructor may take 30 to 90 seconds!!!   I could repro the issue by running the following code: DateTime before =…

2

How to enumerate all certificates on a smart card (PowerShell)

Hi all,   Some time ago I assisted my colleague Jeff Bowles with the development of a PowerShell script which enumerates all certificates on a smart card. Basically the replacement to CAPICOM.Store.Open CAPICOM_SMART_CARD_USER_STORE. He developed a sample that returns a System.Security.Cryptography.X509Certificates.X509Store object with the certificates in the card. The sample tries to emulate what logonUI.exe does during smart…

4

Would you like a free code sample from Microsoft?

Hi all,   Many times I get requests through my blog to provide code samples on some specific topics. Unfortunately I don’t have time to fulfill such requests. Usually the only way for me to be able to do that is if you open what we call an Advisory case with MS Technical Support, a…

0

ExportParameters returns Invalid type specified error

Hi all,   Some time ago a customer of mine was trying to export the private key associated to a certificate stored in a smart card, and for that he was trying to use the RSACryptoServiceProvider.ExportParameters method with a code like the following: “   System.Security.Cryptography.X509Certificates.X509Certificate2 cert = GetCert(certName); RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)cert.PrivateKey; RSAParameters params =…

0

Get-WmiObject : The type initializer for ‘System.Management.MTAHelper’ threw an exception

Hi all,   Sometime ago a customer of mine had some problems in his x64 machine when running WMI queries in Powershell. Take for instance the following query:  ” Get-WMIObject Win32_LogicalDisk ”   It failed with the following error: ” Get-WmiObject : The type initializer for ‘System.Management.MTAHelper’ threw an exception. At line:1 char:14 + Get-WMIObject…

4

System.DirectoryServices.AccountManagement.UserPrincipal.IsMemberOf returns false negatives

Hi all,   Sometime ago a customer of mine faced the following issue on his .NET Framework 3.5 app: System.DirectoryServices.AccountManagement.UserPrincipal.IsMemberOf returned false negatives when the group had more than 1500 members. This means that the function returned false when the user was actually in the group. But everything worked properly with VBScript and ADSI. This turned out to…

2

Global hooks getting lost on Windows 7

Hi all,   Some time ago a customer of mine reported the following issue with SetWindowsHookEx API: Their application had global hooks to monitor for both keyboard and mouse input. On Windows 7, and under high CPU usage, those hooks were getting lost. They tried several things to solve the issue, without success: adjust registry setting “Control…

6