---
title: FAQ - Chain Validation Testing Scenarios
description: "Test chain validation monitoring with automated PowerShell scripts covering 6 scenarios: UntrustedRoot, PartialChain, NotTimeValid, RevocationStatusUnknown, Dev Mode, and Complete Valid Chain."
---

# FAQ - Chain Validation Testing Scenarios

Validate [Chain Validation][] monitoring with automated PowerShell test scripts covering all detection scenarios - from untrusted roots and partial chains (ERROR) to revocation check failures (WARNING) and valid certificate chains (OK).

**What's on This Page:**

* **6 Test Scenarios** - Automated PowerShell 7 scripts for UntrustedRoot, PartialChain, NotTimeValid, RevocationStatusUnknown, Dev Mode, and Complete Valid Chain
* [Batch Testing Script](#fa-tools-batch-testing-script) - Create all test scenarios with configurable flags and error handling
* [Cleanup Script](#fa-broom-cleanup-script) - Remove test certificates after validation testing
* **Validation Checklist** - Verify expected monitoring states match actual results
* **Troubleshooting** - Resolve testing-specific issues (PowerShell errors, chain building)

## Why Test Chain Validation?

Chain validation testing prevents certificate trust failures from causing production outages. Testing ensures monitoring correctly identifies:

* ❌ **UntrustedRoot errors** (ERROR) - Root CA not in trusted store causes application failures
* ❌ **PartialChain errors** (ERROR) - Missing intermediate certificates break trust validation
* ❌ **NotTimeValid errors** (ERROR) - Expired intermediates invalidate entire certificate chains
* ⚠️ **RevocationStatusUnknown warnings** (WARNING) - CRL/OCSP unreachable, potential security gap
* ✅ **Valid chains** (OK) - Complete, trusted certificate chains validate successfully

## Related Documentation

* [Chain Validation][] - Complete feature documentation with detection examples, remediation guidance, and severity explanations
* [Certificate Configuration][] - Configuration options for chain validation, self-signed certificates, and revocation checking

<aside aria-label="Note" class="nodinite-note nodinite-note--note">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-note"></i> Note</p>
<div class="nodinite-note__content"><p>These scripts require <strong>PowerShell 7+</strong> with Administrator privileges for certificate store access.</p></div>
</aside>

<aside aria-label="Warning" class="nodinite-note nodinite-note--warning">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-triangle-exclamation"></i> Warning</p>
<div class="nodinite-note__content"><p>Never deploy test certificates to production environments. Always clean up after validation testing.</p></div>
</aside>

![Chain Validation Example][1]  
*Chain validation showing inline error diagnostics with specific chain errors and remediation recommendations.*

## <i class="fal fa-list-check" aria-hidden="true"></i> Testing Scenarios Overview

|#|Scenario|Purpose|[Expected State][]|Key Focus|  
|---|---|---|---|---|  
|**1**|[Untrusted Root Certificate](#scenario-1-untrusted-root-certificate)|Self-signed cert not in trusted store|❌ **Critical**|UntrustedRoot chain error|  
|**2**|[Partial Chain (Missing Intermediate)](#scenario-2-partial-chain-missing-intermediate)|Certificate without intermediate CA|❌ **Critical**|PartialChain chain error|  
|**3**|[Expired Intermediate Certificate](#scenario-3-expired-intermediate-certificate)|Expired intermediate breaks chain|❌ **Critical**|NotTimeValid chain error|  
|**4**|[Revocation Check Failure](#scenario-4-revocation-check-failure)|CRL/OCSP unreachable|⚠️ **Warning**|RevocationStatusUnknown|  
|**5**|[Valid Chain with Dev Mode](#scenario-5-valid-chain-with-dev-mode)|Self-signed with AllowSelfSigned=true|⚠️ **Warning**|Dev mode severity reduction|  
|**6**|[Complete Valid Chain](#scenario-6-complete-valid-chain)|Properly configured certificate chain|✅ **OK**|All chain validation checks pass|  

## <i class="fal fa-sitemap" aria-hidden="true"></i> Test Scenario Workflow

```mermaid
graph TD
    Start["<i class="fal fa-play" aria-hidden="true"></i> Start Testing"] --> Config["<i class="fal fa-cogs" aria-hidden="true"></i> Configure Scenarios"]
    Config --> S1{"<i class="fal fa-ban" aria-hidden="true"></i> Scenario 1<br/>UntrustedRoot"}
    Config --> S2{"<i class="fal fa-unlink" aria-hidden="true"></i> Scenario 2<br/>PartialChain"}
    Config --> S3{"<i class="fal fa-clock" aria-hidden="true"></i> Scenario 3<br/>Expired Intermediate"}
    Config --> S4{"<i class="fal fa-shield-xmark" aria-hidden="true"></i> Scenario 4<br/>Revocation Failure"}
    Config --> S5{"<i class="fal fa-flask" aria-hidden="true"></i> Scenario 5<br/>Dev Mode"}
    Config --> S6{"<i class="fal fa-check-circle" aria-hidden="true"></i> Scenario 6<br/>Valid Chain"}
    S1 --> V1["<i class="fal fa-times-circle" aria-hidden="true"></i> Critical"]
    S2 --> V2["<i class="fal fa-times-circle" aria-hidden="true"></i> Critical"]
    S3 --> V3["<i class="fal fa-times-circle" aria-hidden="true"></i> Critical"]
    S4 --> V4["<i class="fal fa-triangle-exclamation" aria-hidden="true"></i> Warning"]
    S5 --> V5["<i class="fal fa-triangle-exclamation" aria-hidden="true"></i> Warning"]
    S6 --> V6["<i class="fal fa-circle-check" aria-hidden="true"></i> OK"]
    V1 --> Monitor["<i class="fal fa-eye" aria-hidden="true"></i> Monitor Results"]
    V2 --> Monitor
    V3 --> Monitor
    V4 --> Monitor
    V5 --> Monitor
    V6 --> Monitor
    Monitor --> Validate["<i class="fal fa-check-double" aria-hidden="true"></i> Validate Alerts"]
    Validate --> Cleanup["<i class="fal fa-broom" aria-hidden="true"></i> Cleanup Test Certs"]
    Cleanup --> End["<i class="fal fa-flag-checkered" aria-hidden="true"></i> Testing Complete"]
    style S1 fill:#ffebee
    style S2 fill:#ffebee
    style S3 fill:#ffebee
    style S4 fill:#fff3e0
    style S5 fill:#e3f2fd
    style S6 fill:#e8f5e9
    style V1 fill:#ffcdd2
    style V2 fill:#ffcdd2
    style V3 fill:#ffcdd2
    style V4 fill:#ffe0b2
    style V5 fill:#bbdefb
    style V6 fill:#c8e6c9
```

*Diagram: Chain validation test workflow showing scenario configuration, expected states, and monitoring verification process with color-coded severity levels.*

## <i class="fal fa-vial" aria-hidden="true"></i> Test Scenarios

### Scenario 1: Untrusted Root Certificate

**Purpose**: Validate monitoring detection of self-signed certificates with root CA not in trusted store.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|<i class="fal fa-file-certificate" aria-hidden="true"></i> **Certificate Type**|Self-signed|Creates UntrustedRoot error|  
|<i class="fal fa-tag" aria-hidden="true"></i> **Subject**|`CN=TestCert-UntrustedRoot`|Clearly identifies test purpose|  
|<i class="fal fa-box-archive" aria-hidden="true"></i> **Store Location**|`Cert:\LocalMachine\My`|Standard personal certificate store|  
|<i class="fal fa-ruler" aria-hidden="true"></i> **Key Length**|2048-bit RSA|Minimum secure key size|  
|<i class="fal fa-calendar-day" aria-hidden="true"></i> **Validity Period**|90 days|Short validity for test certificates|  
|<i class="fal fa-key" aria-hidden="true"></i> **Key Usage**|DigitalSignature, KeyEncipherment|Standard SSL/TLS usage|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|<i class="fal fa-link-slash" aria-hidden="true"></i> **Chain Error**|UntrustedRoot|  
|<i class="fal fa-traffic-light" aria-hidden="true"></i> **State**|❌ **Critical** (default) or ⚠️ **Warning** (if `AllowSelfSignedCertificates=true`)|  
|<i class="fal fa-magnifying-glass" aria-hidden="true"></i> **Detection**|Root CA not found in Trusted Root Certification Authorities store|  
|<i class="fal fa-bell" aria-hidden="true"></i> **Alert**|"Untrusted root certificate detected" (if enabled)|  
|<i class="fal fa-wrench" aria-hidden="true"></i> **Remediation**|Install root CA to trusted store OR enable dev mode for testing|  

### Scenario 2: Partial Chain (Missing Intermediate)

**Purpose**: Validate detection of incomplete certificate chains with missing intermediate CA.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|<i class="fal fa-sitemap" aria-hidden="true"></i> **Chain Structure**|Root CA → Intermediate CA → End Entity|Multi-level trust chain|  
|<i class="fal fa-bolt" aria-hidden="true"></i> **Action**|Remove intermediate CA after creation|Simulates missing intermediate|  
|<i class="fal fa-tag" aria-hidden="true"></i> **Subject**|`CN=TestCert-PartialChain`|Identifies test scenario|  
|<i class="fal fa-box-archive" aria-hidden="true"></i> **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|<i class="fal fa-ruler" aria-hidden="true"></i> **Key Length**|2048-bit RSA|Secure key size|  
|<i class="fal fa-calendar-day" aria-hidden="true"></i> **Validity**|90 days (end entity), 180 days (intermediate)|Test certificate lifetimes|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|<i class="fal fa-link-slash" aria-hidden="true"></i> **Chain Error**|PartialChain|  
|<i class="fal fa-traffic-light" aria-hidden="true"></i> **State**|❌ **Critical**|  
|<i class="fal fa-magnifying-glass" aria-hidden="true"></i> **Detection**|Intermediate CA missing from chain path|  
|<i class="fal fa-bell" aria-hidden="true"></i> **Alert**|"Missing intermediate certificate(s) in chain"|  
|<i class="fal fa-wrench" aria-hidden="true"></i> **Remediation**|Download and install missing intermediate CA certificate|  

### Scenario 3: Expired Intermediate Certificate

**Purpose**: Validate detection of expired intermediate CA certificates breaking the chain.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|<i class="fal fa-sitemap" aria-hidden="true"></i> **Chain Structure**|Root CA (valid) → Intermediate CA (expired) → End Entity (valid)|Mixed validity states|  
|<i class="fal fa-calendar-xmark" aria-hidden="true"></i> **Intermediate Expiration**|Already expired OR expires during test|Simulates NotTimeValid error|  
|<i class="fal fa-tag" aria-hidden="true"></i> **Subject**|`CN=TestCert-ExpiredIntermediate`|Identifies test scenario|  
|<i class="fal fa-box-archive" aria-hidden="true"></i> **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|<i class="fal fa-calendar-day" aria-hidden="true"></i> **Root Validity**|365 days|Long-lived root CA|  
|<i class="fal fa-calendar-day" aria-hidden="true"></i> **End Entity Validity**|90 days|Standard certificate lifetime|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|<i class="fal fa-link-slash" aria-hidden="true"></i> **Chain Error**|NotTimeValid|  
|<i class="fal fa-traffic-light" aria-hidden="true"></i> **State**|❌ **Critical**|  
|<i class="fal fa-magnifying-glass" aria-hidden="true"></i> **Detection**|Expired intermediate CA in chain|  
|<i class="fal fa-bell" aria-hidden="true"></i> **Alert**|"Certificate chain contains expired certificate"|  
|<i class="fal fa-wrench" aria-hidden="true"></i> **Remediation**|Renew expired intermediate CA certificate|  

### Scenario 4: Revocation Check Failure

**Purpose**: Validate WARNING state when CRL/OCSP endpoints are unreachable.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|<i class="fal fa-link" aria-hidden="true"></i> **CRL Distribution Point**|Invalid/unreachable URL|Simulates network/firewall issue|  
|<i class="fal fa-link" aria-hidden="true"></i> **OCSP Responder**|Invalid/unreachable URL|Backup revocation method also fails|  
|<i class="fal fa-tag" aria-hidden="true"></i> **Subject**|`CN=TestCert-RevocationFailure`|Identifies test scenario|  
|<i class="fal fa-box-archive" aria-hidden="true"></i> **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|<i class="fal fa-toggle-on" aria-hidden="true"></i> **ValidateRevocation**|`true`|Must be enabled to trigger check|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|<i class="fal fa-link-slash" aria-hidden="true"></i> **Chain Error**|RevocationStatusUnknown|  
|<i class="fal fa-traffic-light" aria-hidden="true"></i> **State**|⚠️ **Warning**|  
|<i class="fal fa-magnifying-glass" aria-hidden="true"></i> **Detection**|Cannot contact CRL/OCSP endpoints|  
|<i class="fal fa-bell" aria-hidden="true"></i> **Alert**|"Unable to verify certificate revocation status"|  
|<i class="fal fa-wrench" aria-hidden="true"></i> **Remediation**|Verify network connectivity, check firewall rules, ensure CRL/OCSP accessible|  

### Scenario 5: Valid Chain with Dev Mode

**Purpose**: Validate `AllowSelfSignedCertificates` configuration downgrades UntrustedRoot to WARNING.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|<i class="fal fa-file-certificate" aria-hidden="true"></i> **Certificate Type**|Self-signed|Would normally be UntrustedRoot|  
|<i class="fal fa-sliders" aria-hidden="true"></i> **Config Setting**|`AllowSelfSignedCertificates=true`|Development/test mode enabled|  
|<i class="fal fa-tag" aria-hidden="true"></i> **Subject**|`CN=TestCert-DevMode`|Identifies test scenario|  
|<i class="fal fa-box-archive" aria-hidden="true"></i> **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|<i class="fal fa-leaf" aria-hidden="true"></i> **Environment**|Development/Test ONLY|Never use in production|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|<i class="fal fa-link-slash" aria-hidden="true"></i> **Chain Error**|UntrustedRoot (detected but severity reduced)|  
|<i class="fal fa-traffic-light" aria-hidden="true"></i> **State**|⚠️ **Warning** (instead of ❌ Critical)|  
|<i class="fal fa-magnifying-glass" aria-hidden="true"></i> **Detection**|Self-signed certificate in dev/test mode|  
|<i class="fal fa-bell" aria-hidden="true"></i> **Alert**|"Self-signed certificate detected (dev mode)"|  
|<i class="fal fa-circle-info" aria-hidden="true"></i> **Note**|Configuration explicitly allows self-signed certs for testing|  

### Scenario 6: Complete Valid Chain

**Purpose**: Validate monitoring correctly identifies healthy certificates with complete, trusted chains.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|<i class="fal fa-file-certificate" aria-hidden="true"></i> **Certificate Type**|CA-issued OR properly configured self-signed chain|Complete trust path|  
|<i class="fal fa-sitemap" aria-hidden="true"></i> **Chain Structure**|Root CA (trusted) → Intermediate CA → End Entity|All certificates valid and trusted|  
|<i class="fal fa-tag" aria-hidden="true"></i> **Subject**|`CN=TestCert-ValidChain`|Identifies test scenario|  
|<i class="fal fa-box-archive" aria-hidden="true"></i> **Store Location**|`Cert:\LocalMachine\My` (end entity), `Cert:\LocalMachine\CA` (intermediate), `Cert:\LocalMachine\Root` (root)|Proper certificate placement|  
|<i class="fal fa-certificate" aria-hidden="true"></i> **All Certificates**|Valid (not expired, not revoked)|No chain errors|  
|<i class="fal fa-shield-halved" aria-hidden="true"></i> **Trust**|Root CA in Trusted Root store|Complete trust chain|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|<i class="fal fa-link-slash" aria-hidden="true"></i> **Chain Error**|None|  
|<i class="fal fa-traffic-light" aria-hidden="true"></i> **State**|✅ **OK**|  
|<i class="fal fa-magnifying-glass" aria-hidden="true"></i> **Detection**|Complete, trusted certificate chain with all validation checks passing|  
|<i class="fal fa-bell" aria-hidden="true"></i> **Alert**|No alert (healthy certificate)|  
|<i class="fal fa-list" aria-hidden="true"></i> **Characteristics**|All certificates time-valid, trusted root, revocation checks pass, no policy violations|  

## <i class="fal fa-tools" aria-hidden="true"></i> Batch Testing Script

**Purpose**: Create all 6 test scenarios with a single PowerShell 7 script.

```powershell
# Chain Validation Testing - Batch Script
# Creates all 6 test scenarios for chain validation monitoring
#
# Requires: PowerShell 7+, Administrator privileges
# Usage: .\Test-ChainValidation.ps1 -Scenarios 1,2,3,4,5,6

param(
    [int[]]$Scenarios = @(1,2,3,4,5,6),  # Which scenarios to create
    [switch]$Verbose                      # Show detailed output
)

Write-Host ("=" * 70) -ForegroundColor Cyan
Write-Host "Chain Validation Test Suite" -ForegroundColor Cyan
Write-Host ("=" * 70) -ForegroundColor Cyan
Write-Host ""

# Scenario 1: UntrustedRoot
if (1 -in $Scenarios) {
    Write-Host "[1/6] Creating UntrustedRoot scenario..." -ForegroundColor Yellow
    $cert1 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-UntrustedRoot, O=Nodinite Chain Testing" `
        -CertStoreLocation "Cert:\LocalMachine\My" `
        -KeyLength 2048 -NotAfter (Get-Date).AddDays(90)
    Write-Host "  ✓ Created: $($cert1.Thumbprint)" -ForegroundColor Green
}

# Scenario 2: PartialChain
if (2 -in $Scenarios) {
    Write-Host "[2/6] Creating PartialChain scenario..." -ForegroundColor Yellow
    $root2 = New-SelfSignedCertificate -Subject "CN=Test Root CA" -CertStoreLocation "Cert:\LocalMachine\My" -KeyUsage CertSign -NotAfter (Get-Date).AddDays(365)
    $int2 = New-SelfSignedCertificate -Subject "CN=Test Intermediate CA" -Signer $root2 -CertStoreLocation "Cert:\LocalMachine\My" -KeyUsage CertSign -NotAfter (Get-Date).AddDays(180)
    $cert2 = New-SelfSignedCertificate -Subject "CN=TestCert-PartialChain" -Signer $int2 -CertStoreLocation "Cert:\LocalMachine\My" -NotAfter (Get-Date).AddDays(90)
    Remove-Item "Cert:\LocalMachine\My\$($int2.Thumbprint)" -Force  # Create partial chain
    Write-Host "  ✓ Created: $($cert2.Thumbprint) (intermediate removed)" -ForegroundColor Green
}

# Scenario 3: NotTimeValid (Expired Intermediate)
if (3 -in $Scenarios) {
    Write-Host "[3/6] Creating NotTimeValid scenario..." -ForegroundColor Yellow
    Write-Host "  ⚠ Note: Requires pre-created expired certificate or manual expiration" -ForegroundColor Yellow
    # This scenario typically requires importing an expired certificate
    # Or using certificate backdating tools not available in standard PowerShell
}

# Scenario 4: RevocationStatusUnknown
if (4 -in $Scenarios) {
    Write-Host "[4/6] Creating RevocationStatusUnknown scenario..." -ForegroundColor Yellow
    $cert4 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-RevocationFailure, O=Nodinite Chain Testing" `
        -CertStoreLocation "Cert:\LocalMachine\My" `
        -KeyLength 2048 -NotAfter (Get-Date).AddDays(90) `
        -Extension @(
            [System.Security.Cryptography.X509Certificates.X509Extension]::new(
                "2.5.29.31",  # CRL Distribution Points
                [Convert]::FromBase64String("MGYwZKBioGCGXmh0dHA6Ly9pbnZhbGlkLXVybC1mb3ItdGVzdGluZy5leGFtcGxlL2NybA=="),
                $false
            )
        )
    Write-Host "  ✓ Created: $($cert4.Thumbprint)" -ForegroundColor Green
}

# Scenario 5: Dev Mode (Self-Signed with AllowSelfSignedCertificates)
if (5 -in $Scenarios) {
    Write-Host "[5/6] Creating Dev Mode scenario..." -ForegroundColor Yellow
    $cert5 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-DevMode, O=Nodinite Chain Testing" `
        -CertStoreLocation "Cert:\LocalMachine\My" `
        -KeyLength 2048 -NotAfter (Get-Date).AddDays(90)
    Write-Host "  ✓ Created: $($cert5.Thumbprint)" -ForegroundColor Green
    Write-Host "  ⚠ Set AllowSelfSignedCertificates=true in agent config" -ForegroundColor Yellow
}

# Scenario 6: Complete Valid Chain
if (6 -in $Scenarios) {
    Write-Host "[6/6] Creating Complete Valid Chain scenario..." -ForegroundColor Yellow
    
    # Create root CA in My store first (New-SelfSignedCertificate requires My store)
    $root6 = New-SelfSignedCertificate `
        -Subject "CN=Test Trusted Root CA, O=Nodinite Chain Testing" `
        -CertStoreLocation "Cert:\LocalMachine\My" `
        -KeyUsage CertSign `
        -NotAfter (Get-Date).AddYears(5)
    
    # Export and import to Root store
    $rootCert = Get-Item "Cert:\LocalMachine\My\$($root6.Thumbprint)"
    Export-Certificate -Cert $rootCert -FilePath "$env:TEMP\TestRootCA.cer" -Force | Out-Null
    Import-Certificate -FilePath "$env:TEMP\TestRootCA.cer" -CertStoreLocation "Cert:\LocalMachine\Root" | Out-Null
    Remove-Item "$env:TEMP\TestRootCA.cer" -Force
    Write-Host "  ✓ Root CA created and copied to Trusted Root store" -ForegroundColor Green
    
    # Create intermediate CA signed by root
    $int6 = New-SelfSignedCertificate `
        -Subject "CN=Test Trusted Intermediate CA, O=Nodinite Chain Testing" `
        -Signer $root6 `
        -CertStoreLocation "Cert:\LocalMachine\My" `
        -KeyUsage CertSign `
        -NotAfter (Get-Date).AddYears(2)
    
    # Export and import to CA store
    $intCert = Get-Item "Cert:\LocalMachine\My\$($int6.Thumbprint)"
    Export-Certificate -Cert $intCert -FilePath "$env:TEMP\TestIntCA.cer" -Force | Out-Null
    Import-Certificate -FilePath "$env:TEMP\TestIntCA.cer" -CertStoreLocation "Cert:\LocalMachine\CA" | Out-Null
    Remove-Item "$env:TEMP\TestIntCA.cer" -Force
    Write-Host "  ✓ Intermediate CA created and copied to CA store" -ForegroundColor Green
    
    # Create end-entity certificate signed by intermediate
    $cert6 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-ValidChain, O=Nodinite Chain Testing" `
        -Signer $int6 `
        -CertStoreLocation "Cert:\LocalMachine\My" `
        -NotAfter (Get-Date).AddDays(365)
    Write-Host "  ✓ Created complete chain: $($cert6.Thumbprint)" -ForegroundColor Green
    
    # Optional: Clean up root and intermediate from My store to avoid duplicates
    Remove-Item "Cert:\LocalMachine\My\$($root6.Thumbprint)" -Force
    Remove-Item "Cert:\LocalMachine\My\$($int6.Thumbprint)" -Force
    Write-Host "  ✓ Chain certificates organized in proper stores" -ForegroundColor Green
}

Write-Host ""
Write-Host ("=" * 70) -ForegroundColor Cyan
Write-Host "Test certificate creation complete!" -ForegroundColor Green
Write-Host "Next: Monitor results in Nodinite Web Client" -ForegroundColor Cyan
Write-Host ("=" * 70) -ForegroundColor Cyan
```

## <i class="fal fa-broom" aria-hidden="true"></i> Cleanup Script

**Purpose**: Remove all test certificates after validation testing.

```powershell
# Chain Validation Cleanup Script
# Removes all test certificates created by the batch testing script
#
# Requires: PowerShell 7+, Administrator privileges
# Usage: .\Cleanup-ChainValidation.ps1

Write-Host "Removing Chain Validation test certificates..." -ForegroundColor Cyan

# Define certificate stores to check
$stores = @(
    "Cert:\LocalMachine\My",
    "Cert:\LocalMachine\CA",
    "Cert:\LocalMachine\Root"
)

$totalRemoved = 0

foreach ($store in $stores) {
    Write-Host "Checking $store..." -ForegroundColor Gray
    
    # Find test certificates in this store
    $testCerts = Get-ChildItem $store -ErrorAction SilentlyContinue | Where-Object {
        $_.Subject -like "*Nodinite Chain Testing*" -or
        $_.Subject -like "CN=TestCert-*" -or
        $_.Subject -like "CN=Test Root CA*" -or
        $_.Subject -like "CN=Test Intermediate CA*" -or
        $_.Subject -like "CN=Test Trusted*"
    }
    
    if ($testCerts) {
        foreach ($cert in $testCerts) {
            Write-Host "  Removing: $($cert.Subject) [$($cert.Thumbprint)]" -ForegroundColor Yellow
            Remove-Item "$store\$($cert.Thumbprint)" -Force -ErrorAction SilentlyContinue
            $totalRemoved++
        }
    }
}

Write-Host ""
if ($totalRemoved -eq 0) {
    Write-Host "No test certificates found." -ForegroundColor Yellow
} else {
    Write-Host "✓ Cleanup complete! Removed $totalRemoved certificate(s)." -ForegroundColor Green
}
```

## <i class="fal fa-eye" aria-hidden="true"></i> Chain Validation Verification

After creating test certificates, verify <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> monitoring detects chain errors correctly:

1. **Wait for discovery** - Allow 1-2 synchronization cycles (5-10 minutes default)
2. **Check [Web Client][]** - Navigate to [Windows Server][] certificate monitoring
3. **Verify states** - Confirm each test certificate shows expected state (Critical/Warning/OK)
4. **Check inline errors** - Expand chain validation to see specific error details
5. **Test alerts** - If enabled, verify alerts triggered for configured error types

![Chain Validation Filtered Resources][2]  
*Filter certificate resources by chain validation state to quickly identify certificates with chain errors requiring remediation.*

**Expected Timeline**:

|Time|Event|  
|---|---|  
|**T+0**|Test certificates created|  
|**T+5 min**|First synchronization cycle discovers certificates|  
|**T+5 min**|Chain validation executes, errors detected|  
|**T+5 min**|Alerts generated (if enabled)|  
|**T+10 min**|Results visible in Web Client|  

## <i class="fal fa-question-circle" aria-hidden="true"></i> Frequently Asked Questions

**Q: Why do I get script errors when running the PowerShell test scripts?**  
**A:** These scripts require **PowerShell 7 or later** with Administrator privileges. Verify your PowerShell version by running `$PSVersionTable.PSVersion` - it should show 7.x or higher. PowerShell 5.1 (Windows PowerShell) has limitations with certificate chain manipulation. Download PowerShell 7+ from [Microsoft's official site](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows)<sup><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>. Additionally, certificate chain operations require Administrator rights to access `Cert:\LocalMachine` stores.

**Q: How do I validate Certificate Chain Validation with <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>?**  
**A:** Run the **Batch Testing Script** (see section above) on your Windows Server to create test scenarios for UntrustedRoot, PartialChain, NotTimeValid, RevocationStatusUnknown, and Dev Mode configurations. The <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> monitoring agent will automatically discover these certificates during its next synchronization cycle and validate their chains according to configured policies. Review the monitoring results in the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> Web Client to verify each certificate shows the expected chain validation state with inline error diagnostics.

**Q: How do I enable Enhanced Chain Validation in <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span>?**  
**A:** Enable the "Enhanced Chain Validation" feature in the [Windows Server Monitoring Agent][] configuration. See the comprehensive [Certificate Configuration][] guide for step-by-step instructions on enabling validation, configuring alert preferences for each error category (UntrustedRoot, PartialChain, RevocationStatusUnknown), setting `AllowSelfSignedCertificates` for dev/test environments, and adjusting cache duration for performance optimization.

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

<i class="fal fa-vial" aria-hidden="true"></i> [Run Chain Validation Test Scripts](#fa-tools-batch-testing-script) - Execute batch testing scenarios  
<i class="fal fa-eye" aria-hidden="true"></i> [Verify Enhanced Chain Validation](#fa-eye-chain-validation-verification) - Confirm expected error categorization  
<i class="fal fa-broom" aria-hidden="true"></i> [Clean Up Test Certificates](#fa-broom-cleanup-script) - Remove test certificates after validation  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

<i class="fal fa-shield-check" aria-hidden="true"></i> [Certificate Overview][]  
<i class="fal fa-chart-line" aria-hidden="true"></i> [Certificate Monitoring][]  
<i class="fal fa-cogs" aria-hidden="true"></i> [Certificate Configuration][]  
<i class="fal fa-question-circle" aria-hidden="true"></i> [FAQ: Weak Cryptography Testing Scenarios][]  
<i class="fal fa-question-circle" aria-hidden="true"></i> [All Certificate Testing FAQs][Certificate Testing FAQs]  
<i class="fal fa-question-circle" aria-hidden="true"></i> [FAQ: Certificates for gMSA Accounts][]  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/MonitorAgent/WindowsServer/Certificates/ChainValidationExample.png
[2]:https://docs.nodinite.com/media/Documentation%20Pictures/MonitorAgent/WindowsServer/Certificates/ChainValidationResources.png

[Certificate Configuration]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/certificates/configuration/
[Certificate Monitoring]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/certificates/monitoring/
[Certificate Overview]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/certificates/overview/
[Certificate Testing FAQs]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/certificates/overview/#fa-hand-point-right-next-steps
[Chain Validation]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/certificates/chain-validation/
[Expected State]:https://docs.nodinite.com/administration/monitor-management/resources/features/expected-state/
[FAQ: Certificates for gMSA Accounts]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/certificates/troubleshooting/faq-certificates-for-gmsa-accounts/
[FAQ: Weak Cryptography Testing Scenarios]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/certificates/troubleshooting/faq-weak-cryptography-testing-scenarios/
[Web Client]:https://docs.nodinite.com/getting-started/overview/
[Windows Server]:https://docs.nodinite.com/logging-and-monitoring/windows-server/features/windows-server/
[Windows Server Monitoring Agent]:https://docs.nodinite.com/logging-and-monitoring/windows-server/overview/