The source code in this directory can be used to build a sample Policy Module
for Microsoft Certificate Services. It is meant to run on Windows Server 2008 R2 or
later. Certificate Services must already be installed.
This policy module should mimic the standalone policy module that ships with
the Windows Server 2008 R2 Certificate Services.
Certificate Services calls the Policy Module through the ICertPolicy
interface, and the Policy Module can call back to Certificate Services
through the ICertServerPolicy interface.
Each time Certificate Services receives a certificate request, it passes
control to the ICertPolicy::VerifyRequest method in policy.cpp. The passed
Context parameter is used with the ICertServerPolicy interface to retrieve
properties from the request and potential certificate. The VerifyRequest
method may add, modify or enable Certificate Extensions, modify the NotBefore
and NotAfter dates and Subject name RDN (Relative Distinguished Name) strings
for the potential certificate. It must also perform any validation required,
and decide the disposition of the request. The method should return one of
VR_PENDING, VR_INSTANT_OK or VR_INSTANT_BAD to cause the request to be made
pending, to grant the request and issue the certificate, or to fail the
request.
To build the sample using the command prompt:
=============================================
1. Open the Command Prompt window and navigate to the directory.
2. Type msbuild [Solution Filename].
To build the sample using Visual Studio 2008 (preferred method):
================================================
1. Open Windows Explorer and navigate to the directory.
2. Double-click the icon for the .sln (solution) file to open the file in Visual Studio.
3. In the Build menu, select Build Solution. The application will be built in the default \Debug or \Release directory.
Once the certpsam.dll DLL is built, its COM interface must be registered
via the following command:
regsvr32 certpsam.dll
Once registered, the Certification Authority management console snapin can
be used to make this the active policy module.
All the registry keys under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CertSvc\Configuration\"Your CA Name"\PolicyModules\CertificateAuthority_MicrosoftDefault.Policy
must be copied to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CertSvc\Configuration\"Your CA Name"\PolicyModules\CertAuthority_Sample.Policy
The Certificate Services service must be stopped and restarted for the sample policy module to load
the new registry settings. Use the Control Panel's Services applet,
and stop and restart the "Certificate Services" service.
Use certutil to retrieve/configure parameters for the sample policy module.
for eg. see "certutil -v -getreg policy" and "certutil -setreg -?" for details.
Files:
------
cedebug.cpp -- Implements debug print routine
ceerror.cpp -- Implements error handling routines
ceformat.cpp -- Implements formatting routine
celib.cpp -- Implements support routines
certpsam.cpp -- Implements COM and initialization entry points:
DllMain
DllCanUnloadNow
DllGetClassObject
DllRegisterServer
DllUnregisterServer
certpsam.def -- Exports COM entry points
certpsam.idl -- Interface Definitions
certpsam.rc -- Version Resource
module.cpp -- Implements ICertManageModule
module.h -- Implements ICertManageModule
pch.cpp -- Precompiled Header file
policy.cpp -- Implements ICertPolicy
policy.h -- Implements ICertPolicy
resource.h -- Resource ID definitions