---
title: FAQ - Private Key Health Testing
description: Test Private Key Health monitoring in Nodinite. PowerShell test scenarios for missing keys, exportable keys, weak key lengths (RSA < 2048, ECDSA < 256), and ECDSA certificates.
---

# FAQ - Private Key Health Testing

Validate [Private Key Health][Private Key Health] monitoring with automated PowerShell test scripts covering all detection scenarios - from missing private keys and exportable keys to weak key lengths and modern ECDSA certificates.

**What's on This Page:**

* **5 Test Scenarios** - Automated PowerShell 7 scripts for Missing Private Keys, Exportable Private Keys, Weak Key Lengths, Healthy Certificates, and ECDSA Certificates
* [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, key export validation)

**Why Test Private Key Health?**

Private key health testing prevents certificate installation errors and security vulnerabilities from causing production outages. Testing ensures monitoring correctly identifies:

* ❌ **Missing private keys** (ERROR) - Certificates without accessible private keys cannot be used for SSL/TLS
* ⚠️ **Exportable private keys** (WARNING) - Security risk where private keys can be extracted
* ⚠️ **Weak key lengths** (WARNING) - RSA < 2048 bits or ECDSA < 256 bits below security standards
* ✅ **Healthy certificates** (OK) - Non-exportable keys with sufficient length
* ✅ **ECDSA certificates** (OK) - Modern elliptic curve cryptography with strong keys

**Related Documentation:** See [Private Key Health][] for complete feature documentation, detection examples, and remediation guidance.

>[!NOTE]
>These scripts require **PowerShell 7+** with Administrator privileges for certificate store access.

>[!WARNING]
>Never deploy test certificates to production environments. Always clean up after validation testing.

## :fa-list-check: Testing Scenarios Overview

|#|Scenario|Purpose|[Expected State][]|Key Focus|  
|---|---|---|---|---|  
|**1**|[Missing Private Key](#scenario-1-certificate-without-private-key)|Certificate without accessible private key|❌ **ERROR**|Unusable certificate detection|  
|**2**|[Exportable Private Key](#scenario-2-certificate-with-exportable-private-key)|Private key marked as exportable|⚠️ **WARNING**|Security risk identification|  
|**3**|[Weak Key Length](#scenario-3-certificate-with-weak-key-length)|RSA 1024-bit (below 2048-bit minimum)|⚠️ **WARNING**|Cryptographic weakness detection|  
|**4**|[Healthy Certificate](#scenario-4-certificate-with-secure-private-key)|Non-exportable 2048-bit RSA key|✅ **OK**|Proper certificate validation|  
|**5**|[ECDSA Certificate](#scenario-5-ecdsa-certificate-with-strong-key)|ECDSA P-256 non-exportable key|✅ **OK**|Modern cryptography support|  

## :fa-sitemap: Test Scenario Workflow

```mermaid
graph TD
    Start[":fa-play: Start Testing"] --> Config[":fa-cogs: Configure Scenarios"]
    Config --> S1{":fa-key-slash: Scenario 1<br/>Missing Key"}
    Config --> S2{":fa-unlock: Scenario 2<br/>Exportable Key"}
    Config --> S3{":fa-shield-xmark: Scenario 3<br/>Weak Key"}
    Config --> S4{":fa-shield-check: Scenario 4<br/>Healthy Cert"}
    Config --> S5{":fa-certificate: Scenario 5<br/>ECDSA Cert"}
    S1 --> V1[":fa-times-circle: Error"]
    S2 --> V2[":fa-triangle-exclamation: Warning"]
    S3 --> V3[":fa-triangle-exclamation: Warning"]
    S4 --> V4[":fa-circle-check: OK"]
    S5 --> V5[":fa-circle-check: OK"]
    V1 --> Monitor[":fa-eye: Monitor Results"]
    V2 --> Monitor
    V3 --> Monitor
    V4 --> Monitor
    V5 --> Monitor
    Monitor --> Validate[":fa-check-double: Validate Alerts"]
    Validate --> Cleanup[":fa-broom: Cleanup Test Certs"]
    Cleanup --> End[":fa-flag-checkered: Testing Complete"]
    style S1 fill:#ffebee
    style S2 fill:#fff3e0
    style S3 fill:#fff3e0
    style S4 fill:#e8f5e9
    style S5 fill:#e8f5e9
    style V1 fill:#ffcdd2
    style V2 fill:#ffe0b2
    style V3 fill:#ffe0b2
    style V4 fill:#c8e6c9
    style V5 fill:#c8e6c9
```

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

## :fa-vial: Test Scenarios

### Scenario 1: Certificate Without Private Key

**Purpose**: Validate ERROR state when certificate has no accessible private key.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|:fa-file-certificate: **Certificate Type**|Imported public key only|Simulates missing private key|  
|:fa-tag: **Subject**|`CN=TestCert-NoPrivateKey`|Identifies test scenario|  
|:fa-box-archive: **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|:fa-key: **Private Key**|**NOT present**|Certificate unusable for SSL/TLS|  
|:fa-calendar-day: **Validity Period**|1 year|Standard test certificate lifetime|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|:fa-key: **HasPrivateKey**|`false`|  
|:fa-traffic-light: **State**|❌ **ERROR**|  
|:fa-magnifying-glass: **Detection**|Certificate cannot be used for SSL/TLS operations|  
|:fa-bell: **Alert**|"Certificate missing private key"|  
|:fa-wrench: **Remediation**|Re-import certificate with private key OR issue new certificate|  

### Scenario 2: Certificate with Exportable Private Key

**Purpose**: Validate WARNING state when private key is marked as exportable (security risk).

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|:fa-file-certificate: **Certificate Type**|Self-signed with exportable private key|Creates security risk scenario|  
|:fa-tag: **Subject**|`CN=TestCert-ExportableKey`|Identifies test scenario|  
|:fa-box-archive: **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|:fa-key: **Private Key**|**Exportable**|Security risk: key can be extracted|  
|:fa-ruler: **Key Length**|2048-bit RSA|Sufficient key length|  
|:fa-calendar-day: **Validity Period**|1 year|Standard test certificate lifetime|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|:fa-key: **HasPrivateKey**|`true`|  
|:fa-file-export: **PrivateKey.Exportable**|`true`|  
|:fa-traffic-light: **State**|⚠️ **WARNING**|  
|:fa-magnifying-glass: **Detection**|Private key can be exported|  
|:fa-bell: **Alert**|"Certificate has exportable private key (security risk)"|  
|:fa-wrench: **Remediation**|Re-issue certificate with non-exportable private key|  

### Scenario 3: Certificate with Weak Key Length

**Purpose**: Validate WARNING state when RSA key length is below 2048 bits.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|:fa-file-certificate: **Certificate Type**|Self-signed with weak key|Creates weak crypto scenario|  
|:fa-tag: **Subject**|`CN=TestCert-WeakKey1024`|Identifies test scenario|  
|:fa-box-archive: **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|:fa-key: **Private Key**|Non-exportable|Secure key storage|  
|:fa-ruler: **Key Length**|**1024-bit RSA**|Below 2048-bit minimum|  
|:fa-calendar-day: **Validity Period**|1 year|Standard test certificate lifetime|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|:fa-key: **HasPrivateKey**|`true`|  
|:fa-ruler: **KeySize**|`1024` bits|  
|:fa-traffic-light: **State**|⚠️ **WARNING**|  
|:fa-magnifying-glass: **Detection**|RSA key length below 2048-bit minimum|  
|:fa-bell: **Alert**|"Certificate uses weak key length (1024 bits, minimum 2048)"|  
|:fa-wrench: **Remediation**|Replace with certificate having 2048-bit or larger RSA key|  

### Scenario 4: Certificate with Secure Private Key

**Purpose**: Validate OK state when certificate has non-exportable private key with sufficient length.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|:fa-file-certificate: **Certificate Type**|Self-signed with secure key|Creates healthy scenario|  
|:fa-tag: **Subject**|`CN=TestCert-HealthyKey2048`|Identifies test scenario|  
|:fa-box-archive: **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|:fa-key: **Private Key**|Non-exportable|Secure key storage|  
|:fa-ruler: **Key Length**|**2048-bit RSA**|Meets security standards|  
|:fa-calendar-day: **Validity Period**|1 year|Standard test certificate lifetime|  

**Expected Results**:

|Aspect|Value|  
|---|---|  
|:fa-key: **HasPrivateKey**|`true`|  
|:fa-file-export: **PrivateKey.Exportable**|`false`|  
|:fa-ruler: **KeySize**|`2048` bits|  
|:fa-traffic-light: **State**|✅ **OK**|  
|:fa-magnifying-glass: **Detection**|Secure private key configuration|  
|:fa-bell: **Alert**|None (healthy certificate)|  

### Scenario 5: ECDSA Certificate with Strong Key

**Purpose**: Validate OK state for modern ECDSA certificates with P-256 curve.

**Configuration**:

|Setting|Value|Rationale|  
|---|---|---|  
|:fa-file-certificate: **Certificate Type**|Self-signed ECDSA certificate|Tests elliptic curve support|  
|:fa-tag: **Subject**|`CN=TestCert-ECDSA-P256`|Identifies test scenario|  
|:fa-box-archive: **Store Location**|`Cert:\LocalMachine\My`|Personal certificate store|  
|:fa-key: **Private Key**|Non-exportable|Secure key storage|  
|:fa-bezier-curve: **Curve**|**P-256 (secp256r1)**|Equivalent to RSA 3072-bit security|  
|:fa-ruler: **Key Size**|256 bits|ECDSA minimum for P-256|  
|:fa-calendar-day: **Validity Period**|1 year|Standard test certificate lifetime|  

**ECDSA Properties**:

|Property|Value|Security Equivalence|  
|---|---|---|  
|**Algorithm**|ECDSA (Elliptic Curve Digital Signature Algorithm)|Modern cryptography|  
|**Curve**|P-256 (NIST secp256r1)|Industry standard|  
|**Key Size**|256 bits|Equivalent to RSA 3072-bit|  
|**Performance**|Faster signing/verification|Lower CPU overhead|  
|**Certificate Size**|Smaller than RSA|Reduced network overhead|  

**ECDSA Advantages**:

* **Smaller key size** - 256-bit ECDSA provides equivalent security to 3072-bit RSA
* **Faster operations** - Signing and verification are computationally more efficient
* **Lower overhead** - Smaller certificate size reduces TLS handshake time
* **Modern standard** - Widely supported by browsers, servers, and cryptographic libraries

**Expected Results**:

|Aspect|Value|  
|---|---|  
|:fa-key: **HasPrivateKey**|`true`|  
|:fa-file-export: **PrivateKey.Exportable**|`false`|  
|:fa-microchip: **Algorithm**|`ECDSA`|  
|:fa-bezier-curve: **Curve**|`P-256 (secp256r1)`|  
|:fa-ruler: **KeySize**|`256` bits|  
|:fa-traffic-light: **State**|✅ **OK**|  
|:fa-magnifying-glass: **Detection**|Strong ECDSA key with secure curve|  
|:fa-bell: **Alert**|None (healthy modern certificate)|  

## :fa-tools: Batch Testing Script

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

```powershell
# Private Key Health Testing - Batch Script
# Creates all 5 test scenarios for private key health monitoring
#
# Requires: PowerShell 7+, Administrator privileges
# Usage: .\Test-PrivateKeyHealth.ps1 -Scenarios 1,2,3,4,5

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

Write-Host "=" * 70 -ForegroundColor Cyan
Write-Host "Private Key Health Test Suite" -ForegroundColor Cyan
Write-Host "=" * 70 -ForegroundColor Cyan
Write-Host ""

# Scenario 1: Missing Private Key
if (1 -in $Scenarios) {
    Write-Host "[1/5] Creating Missing Private Key scenario..." -ForegroundColor Yellow
    
    # Create certificate with private key
    $tempCert = New-SelfSignedCertificate `
        -Subject "CN=TestCert-NoPrivateKey, O=Nodinite Private Key Testing" `
        -CertStoreLocation Cert:\LocalMachine\My `
        -KeyLength 2048 -NotAfter (Get-Date).AddYears(1)
    
    # Export public key only
    $certPath = "$env:TEMP\NoPrivateKey.cer"
    Export-Certificate -Cert $tempCert -FilePath $certPath -Force | Out-Null
    
    # Remove certificate with private key
    Remove-Item "Cert:\LocalMachine\My\$($tempCert.Thumbprint)" -Force
    
    # Re-import public key only (no private key)
    $cert1 = Import-Certificate -FilePath $certPath -CertStoreLocation Cert:\LocalMachine\My
    Remove-Item $certPath -Force
    
    Write-Host "  ✓ Created: $($cert1.Thumbprint) (NO private key)" -ForegroundColor Green
}

# Scenario 2: Exportable Private Key
if (2 -in $Scenarios) {
    Write-Host "[2/5] Creating Exportable Private Key scenario..." -ForegroundColor Yellow
    $cert2 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-ExportableKey, O=Nodinite Private Key Testing" `
        -CertStoreLocation Cert:\LocalMachine\My `
        -KeyLength 2048 -KeyExportPolicy Exportable -NotAfter (Get-Date).AddYears(1)
    Write-Host "  ✓ Created: $($cert2.Thumbprint) (EXPORTABLE private key)" -ForegroundColor Green
}

# Scenario 3: Weak Key Length (1024-bit RSA)
if (3 -in $Scenarios) {
    Write-Host "[3/5] Creating Weak Key Length scenario (1024-bit)..." -ForegroundColor Yellow
    $cert3 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-WeakKey1024, O=Nodinite Private Key Testing" `
        -CertStoreLocation Cert:\LocalMachine\My `
        -KeyLength 1024 -KeyExportPolicy NonExportable -NotAfter (Get-Date).AddYears(1)
    Write-Host "  ✓ Created: $($cert3.Thumbprint) (1024-bit RSA key)" -ForegroundColor Green
}

# Scenario 4: Healthy Certificate (2048-bit RSA, non-exportable)
if (4 -in $Scenarios) {
    Write-Host "[4/5] Creating Healthy Certificate scenario (2048-bit)..." -ForegroundColor Yellow
    $cert4 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-HealthyKey2048, O=Nodinite Private Key Testing" `
        -CertStoreLocation Cert:\LocalMachine\My `
        -KeyLength 2048 -KeyExportPolicy NonExportable -NotAfter (Get-Date).AddYears(1)
    Write-Host "  ✓ Created: $($cert4.Thumbprint) (2048-bit RSA, non-exportable)" -ForegroundColor Green
}

# Scenario 5: ECDSA Certificate (P-256, non-exportable)
if (5 -in $Scenarios) {
    Write-Host "[5/5] Creating ECDSA Certificate scenario (P-256)..." -ForegroundColor Yellow
    $cert5 = New-SelfSignedCertificate `
        -Subject "CN=TestCert-ECDSA-P256, O=Nodinite Private Key Testing" `
        -CertStoreLocation Cert:\LocalMachine\My `
        -KeyAlgorithm ECDSA_secp256r1 `
        -KeyExportPolicy NonExportable -NotAfter (Get-Date).AddYears(1)
    Write-Host "  ✓ Created: $($cert5.Thumbprint) (ECDSA P-256, non-exportable)" -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
```

## :fa-broom: Cleanup Script

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

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

Write-Host "Removing Private Key Health test certificates..." -ForegroundColor Cyan

# Find and remove test certificates
$testCerts = Get-ChildItem Cert:\LocalMachine\My|Where-Object {
    $_.Subject -like "*Nodinite Private Key Testing*" -or
    $_.Subject -like "CN=TestCert-NoPrivateKey*" -or
    $_.Subject -like "CN=TestCert-ExportableKey*" -or
    $_.Subject -like "CN=TestCert-WeakKey*" -or
    $_.Subject -like "CN=TestCert-HealthyKey*" -or
    $_.Subject -like "CN=TestCert-ECDSA*"
}

if ($testCerts.Count -eq 0) {
    Write-Host "No test certificates found." -ForegroundColor Yellow
} else {
    Write-Host "Found $($testCerts.Count) test certificate(s)" -ForegroundColor White
    foreach ($cert in $testCerts) {
        Write-Host "  Removing: $($cert.Subject) [$($cert.Thumbprint)]" -ForegroundColor Gray
        Remove-Item "Cert:\LocalMachine\My\$($cert.Thumbprint)" -Force
    }
    Write-Host "✓ Cleanup complete!" -ForegroundColor Green
}
```

## :fa-eye: Private Key Health Verification

After creating test certificates, verify :Nodinite: monitoring detects private key issues 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 (Error/Warning/OK)
4. **Check inline errors** - Expand private key health details to see specific issues
5. **Test alerts** - If enabled, verify alerts triggered for configured error types

**Expected Timeline**:

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

## :fa-question-circle: 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 key export policies. Download PowerShell 7+ from [Microsoft's official site](https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell-on-windows)<sup>:fa-arrow-up-right-from-square:</sup>. Additionally, certificate operations require Administrator rights to access `Cert:\LocalMachine` stores.

**Q: How do I validate Private Key Health monitoring with :Nodinite:?**  
**A:** Run the **Batch Testing Script** (see section above) on your Windows Server to create test scenarios for Missing Private Keys, Exportable Private Keys, Weak Key Lengths, Healthy Certificates, and ECDSA Certificates. The :Nodinite: monitoring agent will automatically discover these certificates during its next synchronization cycle and validate their private key health according to configured policies. Review the monitoring results in the :Nodinite: Web Client to verify each certificate shows the expected private key health state with inline error diagnostics.

**Q: How do I enable Private Key Health monitoring in :Nodinite:?**  
**A:** Enable private key health validation 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 missing keys and exportable keys, setting minimum key length thresholds (RSA 2048-bit, ECDSA 256-bit), and adjusting cache duration for performance optimization.

## :fa-hand-point-right: Next Steps

:fa-vial: [Run Private Key Health Test Scripts](#fa-tools-batch-testing-script) - Execute batch testing scenarios  
:fa-eye: [Verify Private Key Health Validation](#fa-eye-private-key-health-verification) - Confirm expected error categorization  
:fa-broom: [Clean Up Test Certificates](#fa-broom-cleanup-script) - Remove test certificates after validation  

## :fa-link-horizontal: Related Topics

:fa-certificate: [Private Key Health][]  
:fa-cogs: [Certificate Configuration][]  
:fa-question-circle: [FAQ: Certificate Purpose and EKU Testing][]  
:fa-question-circle: [FAQ: Weak Cryptography Testing][]  

[Certificate Configuration]:{ndr}/Logging%20and%20Monitoring/Windows%20Server/Features/Certificates/Configuration.md
[Expected State]:{ndr}/Administration/2.%20Monitor%20Management/3.%20Resources/Features/Expected%20State.md
[FAQ: Certificate Purpose and EKU Testing]:{ndr}/Logging%20and%20Monitoring/Windows%20Server/Features/Certificates/Troubleshooting/FAQ%20-%20Certificate%20Purpose%20and%20EKU%20Testing%20Scenarios.md
[FAQ: Weak Cryptography Testing]:{ndr}/Logging%20and%20Monitoring/Windows%20Server/Features/Certificates/Troubleshooting/FAQ%20-%20Weak%20Cryptography%20Testing%20Scenarios.md
[Private Key Health]:{ndr}/Logging%20and%20Monitoring/Windows%20Server/Features/Certificates/Private%20Key%20Health.md
[Web Client]:{ndr}/Getting%20Started/Overview.md
[Windows Server]:{ndr}/Logging%20and%20Monitoring/Windows%20Server/Features/Windows%20Server.md
[Windows Server Monitoring Agent]:{ndr}/Logging%20and%20Monitoring/Windows%20Server/Overview.md