Search code examples
c#.netcryptographycertificatecapicom

CAPICOM vs P/Invoke


I would like to use CryptoAPI in C# to access certificate store and sign message.

This MSDN article "CAPICOM: CryptoAPI Made Easy" shows 2 way to do that: using CAPICOM or P/Invoke.

  1. Which is best? CAPICOM.dll or P/Invoke [DllImport("crypt32.dll", ...)]

  2. Will "crypt32.dll" always be present on any machine?


Solution

  • CAPICOM is an old technology that has/is being deprecated by Microsoft. P/Invoke (Platform Invoke) allows managed code to call unmanaged code that are implemented in a DLL.

    It is a COM-based wrapper for the CryptoAPI library. The article you posted is from 2003. That was over 8 years ago and technology has moved on.

    This article at MSDN here recommends you use the .NET framework for security features in lieu of CAPICOM.