How to create a certificate request with CertEnroll and .NET (C#)

Hi all, The following C# sample shows how to use CertEnroll COM component to create a certificate request, send the request to the CA, get the response from the CA, and install the new certificate in the machine: (Note that this sample is a WinForms app with 3 buttons -createRequestButton, sendRequestButton, acceptPKCS7Button- and 2 textboxes -requestText…

102

How to create a certificate request with CertEnroll (JavaScript)

Hi all, The following Javascript sample shows how to use CertEnroll COM component to create a certificate request:<html> <head> <title>Certificate Request test</title> </head> <body> <object id=”objCertEnrollClassFactory” classid=”clsid:884e2049-217d-11da-b2a4-000e7bbb2b09″></object> <script language=”javascript”> function CreateRequest() { document.write(“<br>Create Request…”); try { // Variables var objCSP = objCertEnrollClassFactory.CreateObject(“X509Enrollment.CCspInformation”); var objCSPs = objCertEnrollClassFactory.CreateObject(“X509Enrollment.CCspInformations”); var objPrivateKey = objCertEnrollClassFactory.CreateObject(“X509Enrollment.CX509PrivateKey”); var objRequest = objCertEnrollClassFactory.CreateObject(“X509Enrollment.CX509CertificateRequestPkcs10”) var…

54

How to get Antivirus information with WMI (VBScript)

Hi all, welcome back, As we read in Windows Security Center – Managing the State of Security, the vast majority of antivirus Independent Software Vendors (ISVs) support WMI integration. Windows Security Center uses it to detect antivirus and firewall solutions. The following script shows how to get some information from those solutions:  strComputer = “.”…

37

Controls won’t get resized once the nesting hierarchy of windows exceeds a certain depth (x64)

Hi all, welcome back, I’ve been working on an issue where WM_SIZE events are not properly generated once the nesting hierarchy of windows exceeds a certain depth. This issue only occurs on current x64 Windows: like XP, Server 2008 or the latest Windows 7. For ilustration purposes, let’s imagine we have a C# application which creates…

33

.NET and the XAdES standard

Hi all,   You may know already that SignedXml class in .NET doesn’t support the XML Advanced Electronic Signatures (XAdES) standard (more info here: Which standards does SignedXml support?) Fortunatelly my colleagues in Microsoft France developed a XAdES library for .NET (Microsoft.Xades.dll) that they published on this French site: Kit de démarrage « Signature avancée (XAdES) pour Microsoft .NET…

28

How to Sign and Verify the signature with .NET and a certificate (C#)

Hi all, Today I’m posting a sample which shows how to sign a text with a certificate in my Personal store (this cert will have public and private key associated to it) and how to verify that signature with a .cer file (for i.e. WinForms) applications or a client certificate (for i.e. ASP.NET) (both will…

23

How to get the logged on user with WMI (VBScript)

Hi all, welcome back, From time to time I get to do some scripting, play with LDAP/ADSI, WMI, etc. I’ll begin posting some VBScript samples I have which may be useful for you too. Today we’ll see a way to get the user who has logged on a given machine with VBScript & WMI:  ‘…

23

How to get a list of all users in an OU (VBScript)

Hi all, welcome back, Today I’ll post a very straight forward sample which gets a list of all users in an Organizational Unit (OU) in Active Directory (AD) using VBScript:’ Get OU ‘ strOU = “OU=Users,DC=domain,DC=com” ‘ Create connection to AD ‘ Set objConnection = CreateObject(“ADODB.Connection”) objConnection.Open “Provider=ADsDSOObject;” ‘ Create command ‘ Set objCommand =…

18

How to import a certificate without user interaction (C++ & C#)

Hi, welcome back, Today I’m posting a CryptoAPI sample which uses CryptUIWizImport to import a certificate without any user interaction:   <SAMPLE Language=”C++”>CRYPTUI_WIZ_IMPORT_SRC_INFO importSrc; memset(&importSrc, 0, sizeof(CRYPTUI_WIZ_IMPORT_SRC_INFO)); importSrc.dwSize = sizeof(CRYPTUI_WIZ_IMPORT_SRC_INFO); importSrc.dwSubjectChoice = CRYPTUI_WIZ_IMPORT_SUBJECT_FILE; importSrc.pwszFileName = L”C:\\PathToPFX\\cert.pfx”; importSrc.pwszPassword = L”PasswordToDecryptPFX”; importSrc.dwFlags = CRYPT_EXPORTABLE | CRYPT_USER_PROTECTED;   if (CryptUIWizImport( CRYPTUI_WIZ_NO_UI, NULL, NULL, &importSrc,   NULL ) == 0)…

17

RSACryptoServiceProvider fails when used with ASP.NET

Hi, welcome back, I will talk today about a very common issue we face when we try to use .NET’s RSACryptoServiceProvider class in ASP.NET. When we try to create a new RSACryptoServiceProvider object in this scenario, we may get the following exception: “System.Security.Cryptography.CryptographicException: The system cannot find the file specified”.   By using my CryptoAPI Tracer…

16