### Install TameMyCerts with policy directory
Source: https://docs.tamemycerts.com/
Run install.ps1 as local Administrator, specifying the local path for XML configuration files. The script registers the module, creates registry values, and configures the policy module as active. The certification authority service is restarted during installation.
```powershell
.\install.ps1 -PolicyDirectory C:\PolicyFiles
```
--------------------------------
### Set certsvc to delayed-auto start
Source: https://docs.tamemycerts.com/
Use this command to set the Certification Authority service to 'Automatic (Delayed Start)' to circumvent the boot-time startup failure caused by the .NET Runtime not being available.
```powershell
sc.exe config certsvc start=delayed-auto
```
--------------------------------
### Unblock downloaded files
Source: https://docs.tamemycerts.com/
Run this PowerShell command in the directory where the TameMyCerts files were unzipped to remove the Mark of the Web so the installer script can be executed.
```powershell
Get-ChildItem -Path * -Recurse | Unblock-File
```
--------------------------------
### NotAfter configuration example for fixed expiration date
Source: https://docs.tamemycerts.com/
This example sets all certificates to expire on Dec 31, 2022 23:59:59 Europe/Berlin (UTC+1) time. After that date has passed, all certificate requests for this template get denied.
```xml
2022-12-31T23:59:59.0000000+01:00
```
--------------------------------
### Directory object rule configuration example
Source: https://docs.tamemycerts.com/
XML configuration for a directory object rule that evaluates the 'description' attribute, requires it to be present, and denies requests if the value matches the regex '^Admin$'.
```xml
description
true
^Admin$
RegEx
Deny
```
--------------------------------
### Example policy restricting commonName to 'Hello World'
Source: https://docs.tamemycerts.com/
A basic policy that requires the commonName field to match the pattern '^Hello World$'. All other requests are denied. This applies to offline certificate templates.
```XML
commonName
true
^Hello World$
```
--------------------------------
### Submit certificate request with StartDate and ExpirationDate
Source: https://docs.tamemycerts.com/
Example certreq command that requests a certificate valid from Mar 1, 2022 08:00 to Mar 1, 2022 16:00. Uses the StartDate and ExpirationDate attributes in RFC 2616 format.
```bash
certreq.exe -config "caserver.tamemycerts.local\TameMyCerts CA" -attrib "CertificateTemplate:TameMyCertsWebServer\nStartDate:Tue, 1 Mar 2022 08:00:00 GMT\nExpirationDate:Tue, 1 Mar 2022 16:00:00 GMT" -submit "MyCertificateRequest.req"
```
--------------------------------
### Basic CertificateRequestPolicy XML template
Source: https://docs.tamemycerts.com/
Starts every policy configuration file. The root element is CertificateRequestPolicy with XML schema namespaces. Directives are placed inside the root element.
```XML
```
--------------------------------
### Configure OCSP URIs per template
Source: https://docs.tamemycerts.com/
Use the OnlineCertificateStatusProtocol directive to issue Online Certificate Status Protocol URIs on a per-template basis. The example shows a single OCSP URI.
```xml
http://ocsp.tamemycerts.com/ocsp
```
--------------------------------
### Suppress unqualified names with SupplementUnqualifiedNames
Source: https://docs.tamemycerts.com/
Shows the configuration to suppress supplementation of unqualified DNS names (e.g. 'host') by setting SupplementUnqualifiedNames to false. The example includes the DirectoryServicesMapping block with SupplementServicePrincipalNames enabled.
```xml
true
false
```
--------------------------------
### Create Certificate Signing Request with yubico-piv-tool
Source: https://docs.tamemycerts.com/
Creates a Certificate Signing Request using the public key from pubkey.key and saves it to request.csr. Uses the attestation action and verifies the PIN.
```bash
yubico-piv-tool --slot=9a --subject="/CN=this-is-a-test/" --input=pubkey.key --attestation --output=request.csr --action=verify-pin --action=request
```
--------------------------------
### Transfer first SAN dNSName to commonName
Source: https://docs.tamemycerts.com/
Transfers the first dNSName from the Subject Alternative Name (SAN) into the commonName field. This example does not require DirectoryServicesMapping.
```xml
commonName
{san:dNSName}
true
true
```
--------------------------------
### Generate key pair with yubico-piv-tool
Source: https://docs.tamemycerts.com/
Creates a key pair on the YubiKey PIV slot 9a and saves the public key to pubkey.key. Uses ECCP384 algorithm with pin-policy once and touch-policy cached.
```bash
yubico-piv-tool --slot=9a --action=generate --pin-policy=once --touch-policy=cached --algorithm=ECCP384 --output=pubkey.key
```
--------------------------------
### Create YKROOT and YKCA certificate stores
Source: https://docs.tamemycerts.com/
Creates the YKROOT and YKCA certificate stores under the LocalMachine store on the certification authority server. Required for the attestation certificate chain to be built.
```powershell
Set-Location -Path Cert:\LocalMachine
New-Item -Name YKROOT
New-Item -Name YKCA
```
--------------------------------
### New syntax for Patterns (version 1.1)
Source: https://docs.tamemycerts.com/
Shows the XML configuration for SubjectRule using Patterns with Pattern elements and Action directives as used in TameMyCerts version 1.1 and newer. This replaces the old AllowedPatterns and DisallowedPatterns syntax.
```xml
commonName
^[-_a-zA-Z0-9]*\.tamemycerts\.com$
^.*(porn|gambling).*$
Deny
```
--------------------------------
### Uninstall TameMyCerts
Source: https://docs.tamemycerts.com/
Run install.ps1 as Administrator with the -Uninstall parameter. The script unregisters the module, copies registry settings back, and configures the Windows Default policy module as active. The certification authority service is restarted during uninstallation.
```powershell
.\install.ps1 -Uninstall
```
--------------------------------
### Configure AIA URIs per template
Source: https://docs.tamemycerts.com/
Use the AuthorityInformationAccess directive to issue Authority Information Access URIs on a per-template basis. The example uses token variables like %1, %3, %4, %7, %6, %11.
```xml
http://%1/CertData/%3%4.crt
ldap:///CN=%7,CN=AIA,CN=Public Key Services,CN=Services,%6%11
```
--------------------------------
### Configure CDP URIs per template
Source: https://docs.tamemycerts.com/
Use the CrlDistributionPoints directive to issue Certificate Revocation List Distribution Point URIs on a per-template basis. The example uses token variables like %1, %3, %8, %9, %6, %10.
```xml
http://%1/CertData/%3%8%9.crl
ldap:///CN=%7%8,CN=%3,CN=cdp,CN=Public Key Services,CN=Services,%6%10
```
--------------------------------
### Enable DirectoryServicesMapping with defaults for user objects (offline template)
Source: https://docs.tamemycerts.com/
Enables the mapping with default values for user objects in an offline template. The empty element uses all default settings.
```xml
```
--------------------------------
### Append static string to commonName from name attribute
Source: https://docs.tamemycerts.com/
Builds the commonName from the Active Directory name attribute and appends a static string. For example, if name is "John Doe", the commonName becomes "John Doe is an awesome fellow!".
```xml
commonName
{ad:name} is an awesome fellow!
true
true
```
--------------------------------
### Enable DirectoryServicesMapping with defaults for computer objects (offline template)
Source: https://docs.tamemycerts.com/
Enables the mapping with default values for computer objects in an offline template. The element contains child directives to specify the certificate attribute, directory services attribute, and object category.
```xml
dNSName
dNSHostName
computer
```
--------------------------------
### Enable certificate template auto-enrollment via registry (PowerShell)
Source: https://docs.tamemycerts.com/
Creates the AutoEnrollment registry key and sets the AEPolicy value to 0x1 to enable the certificate AutoEnrollment Process, which is required for TameMyCerts to recognize certificate templates.
```powershell
New-Item -Path HKLM:\Software\Policies\Microsoft\Cryptography\AutoEnrollment
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Cryptography\AutoEnrollment -Name AEPolicy -Value 0x1 -Force
```
--------------------------------
### Build commonName from sn and givenName
Source: https://docs.tamemycerts.com/
Builds the commonName from the Active Directory attributes sn (surname) and givenName, formatted as "surname, givenName". For example, givenName "John" and surname "Doe" produce commonName "Doe, John".
```xml
commonName
{ad:sn}, {ad:givenName}
true
true
```
--------------------------------
### Import YubiKey attestation Root CA certificates into YKROOT store
Source: https://docs.tamemycerts.com/
Imports all .cer files in the current directory into the YKROOT certificate store using certutil. Used for YubiKey attestation Root CA certificates.
```powershell
Get-ChildItem -Path *.cer | ForEach-Object -Process { certutil -addstore YKROOT $_.FullName }
```
--------------------------------
### Allow only Autoenrollment with AllowedProcesses
Source: https://docs.tamemycerts.com/
This configuration restricts certificate enrollment to only the Windows Autoenrollment process (taskhostw.exe). All other processes will be denied.
```xml
taskhostw.exe
```
--------------------------------
### Accept commonName and dNSName with DNS supplementation
Source: https://docs.tamemycerts.com/
Full configuration that accepts certificate requests with a mandatory commonName and optional dNSName within the tamemycerts.com domain. If no dNSName SAN is present, the commonName value is used to create a SAN extension.
```XML
commonName
true
^[-_a-zA-Z0-9]*\.tamemycerts\.com$
dNSName
false
^[-_a-zA-Z0-9]*\.tamemycerts\.com$
true
```
--------------------------------
### Event ID 2 Sample Message
Source: https://docs.tamemycerts.com/
Sample log message for Event ID 2, an error event indicating failure to initialize the Windows Default policy module. Placeholder {0} contains the error message.
```text
Error initializing Windows Default policy module:
{0}
```
--------------------------------
### Inspect a certificate request with certutil -dump
Source: https://docs.tamemycerts.com/
Use this command to dump a certificate request file and inspect its contents, including the process name used to create the request. Replace with the actual file name.
```bash
certutil -dump
```
--------------------------------
### Event ID 1 Sample Message
Source: https://docs.tamemycerts.com/
Sample log message for Event ID 1, an information event indicating the policy module is ready. Placeholder {0} is replaced with the policy module name and version.
```text
{0} policy module version {1} is ready to process incoming certificate requests.
```
--------------------------------
### Old syntax for AllowedPatterns and DisallowedPatterns (version 1.0)
Source: https://docs.tamemycerts.com/
Shows the XML configuration for SubjectRule using AllowedPatterns and DisallowedPatterns as used in TameMyCerts version 1.0. This syntax is replaced in version 1.1.
```xml
commonName
^[-_a-zA-Z0-9]*\.tamemycerts\.com$
^.*(porn|gambling).*$
```
--------------------------------
### PermitEmptyIdentites directive
Source: https://docs.tamemycerts.com/
Set to true to allow certificate requests that would result in certificates without an identity. By default, TameMyCerts denies such requests and logs an event.
```XML
true
```
--------------------------------
### Set CA LogLevel and Restart Service
Source: https://docs.tamemycerts.com/
Commands to set the certification authority's LogLevel registry value and restart the certsvc service to apply the change. The {LogLevel} placeholder should be replaced with a numeric value from the table (e.g., 4 for CERTLOG_VERBOSE).
```bash
certutil -setreg CA\Loglevel {LogLevel}
net stop certsvc
net start certsvc
```
--------------------------------
### Enable SupplementDnsNames directive
Source: https://docs.tamemycerts.com/
Enables the feature to supplement DNS names from the commonName into the SAN extension. This is a minimal configuration.
```XML
true
```
--------------------------------
### Enable TMC_DENY_IF_NO_POLICY flag with certutil
Source: https://docs.tamemycerts.com/
Use this command in an elevated command prompt to enable the TMC_DENY_IF_NO_POLICY flag (0x1). Adjust the flag value as needed.
```plaintext
certutil -setreg Policy\TmcFlags +0x1
```
--------------------------------
### Old syntax for Subject DN mapping (version 1.5 and lower)
Source: https://docs.tamemycerts.com/
Shows the XML configuration for modifying the Subject Distinguished Name using the DirectoryServicesMapping element, as used in TameMyCerts version 1.5 and lower. This syntax is replaced in version 1.6.
```xml
emailAddress
mail
true
```
--------------------------------
### Import YubiKey intermediate CA certificates into YKCA store
Source: https://docs.tamemycerts.com/
Imports all .cer files in the current directory into the YKCA certificate store using certutil. Applies to YubiKeys with Firmware 5.7.4 or newer.
```powershell
Get-ChildItem -Path *.cer | ForEach-Object -Process { certutil -addstore YKCA $_.FullName }
```