FAQ - Private Key Health Testing
Section titled “FAQ - Private Key Health Testing”Validate 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 healthy configurations.
What's on This Page:
- 5 Test Scenarios - Configuration tables for Missing Private Key, Exportable Key, Weak Key Length, Healthy Certificate, and ECDSA Certificate
- Batch Testing Script - Create all 5 test scenarios at once
- Usage Instructions - Step-by-step guide for running scripts and verifying monitoring
- Troubleshooting - Resolve common testing issues
Why Test Private Key Health Monitoring?
Private key health testing validates that monitoring correctly identifies:
- ❌ Missing private keys (ERROR) - Certificate exists but private key inaccessible
- ⚠️ Exportable private keys (WARNING) - Security risk from keys that can be exported
- ⚠️ Weak key lengths (WARNING) - RSA < 2048 bits or ECDSA < 256 bits
- ✅ Healthy certificates (OK) - Non-exportable keys with sufficient length
Related Documentation: See Private Key Health for complete feature documentation and security best practices.
Testing Scenarios Overview
Section titled “ Testing Scenarios Overview”Create comprehensive test certificates to validate all aspects of certificate monitoring and private key health detection:
| Scenario | Test Case | Expected State | Description |
|---|---|---|---|
| 1. Missing Private Key | Certificate without accessible private key | ❌ Error | Tests detection when certificate exists but private key is missing or inaccessible |
| 2. Exportable Private Key | Certificate with exportable private key | ⚠️ Warning | Tests security risk detection for private keys that can be exported |
| 3. Weak Cryptography | 1024-bit RSA certificate | ⚠️ Warning | Tests detection of cryptographically weak key lengths |
| 4. Healthy Certificate | 2048-bit non-exportable RSA | ✅ OK | Tests baseline monitoring for properly configured certificates |
| 5. ECDSA Certificate | ECDSA P-256 non-exportable | ✅ OK | Tests modern elliptic curve cryptography support |
Quick Start Options
Section titled “ Quick Start Options”- Individual Testing: Jump to specific scenarios using the links above
- Comprehensive Testing: Use the Batch Testing Script to create all scenarios at once
- Validation Guide: Follow Usage Instructions for monitoring verification steps
Testing Scenario 1: Certificate Without Private Key
Section titled “ Testing Scenario 1: Certificate Without Private Key”Use Case: Test monitoring detection of certificates where the private key is missing or inaccessible.
PowerShell Script
Section titled “ PowerShell Script”# Create certificate with private key, then export/import to remove private key accessWrite-Host "Creating certificate without accessible private key..." -ForegroundColor Cyan
# Step 1: Create certificate with private key$cert = New-SelfSignedCertificate ` -Subject "CN=TestCert-NoPrivateKey, O=Nodinite Testing" ` -CertStoreLocation "Cert:\LocalMachine\My" ` -KeyLength 2048 ` -KeyAlgorithm RSA ` -HashAlgorithm SHA256 ` -NotAfter (Get-Date).AddDays(90) ` -KeyUsage DigitalSignature, KeyEncipherment
Write-Host "✓ Certificate created with thumbprint: $($cert.Thumbprint)" -ForegroundColor Green
# Step 2: Export certificate without private key$exportPath = "$env:TEMP\TestCert-NoPrivateKey.cer"Export-Certificate -Cert $cert -FilePath $exportPath -Type CERTWrite-Host "✓ Certificate exported to: $exportPath" -ForegroundColor Green
# Step 3: Remove original certificate (with private key)Remove-Item -Path "Cert:\LocalMachine\My\$($cert.Thumbprint)" -ForceWrite-Host "✓ Original certificate with private key removed" -ForegroundColor Yellow
# Step 4: Import certificate back (without private key)$importedCert = Import-Certificate -FilePath $exportPath -CertStoreLocation "Cert:\LocalMachine\My"Write-Host "✓ Certificate re-imported without private key access" -ForegroundColor GreenWrite-Host " Thumbprint: $($importedCert.Thumbprint)" -ForegroundColor White
# Verification$testCert = Get-Item -Path "Cert:\LocalMachine\My\$($importedCert.Thumbprint)"if ($testCert.HasPrivateKey) { Write-Host "⚠️ Certificate shows HasPrivateKey=True but private key may not be accessible" -ForegroundColor Yellow} else { Write-Host "✓ Certificate HasPrivateKey=False - monitoring should detect missing private key" -ForegroundColor Green}
# Cleanup instructionWrite-Host "`n:fa-broom: Cleanup Command:" -ForegroundColor MagentaWrite-Host "Remove-Item 'Cert:\LocalMachine\My\$($importedCert.Thumbprint)' -Force" -ForegroundColor WhiteExpected Result - Scenario 1
Section titled “ Expected Result - Scenario 1”- State: ❌ Error
- Detection: Certificate exists but private key is missing or inaccessible
- Alert: Private key health check failure
Testing Scenario 2: Exportable Private Key
Section titled “ Testing Scenario 2: Exportable Private Key”Use Case: Test monitoring detection of certificates with exportable private keys (security risk).
Scenario 2 Script
Section titled “ Scenario 2 Script”# Create certificate with exportable private keyWrite-Host "Creating certificate with exportable private key..." -ForegroundColor Cyan
$cert = New-SelfSignedCertificate ` -Subject "CN=TestCert-ExportableKey, O=Nodinite Testing" ` -CertStoreLocation "Cert:\LocalMachine\My" ` -KeyLength 2048 ` -KeyAlgorithm RSA ` -HashAlgorithm SHA256 ` -KeyExportPolicy Exportable ` -NotAfter (Get-Date).AddDays(90) ` -KeyUsage DigitalSignature, KeyEncipherment
Write-Host "✓ Certificate created with exportable private key" -ForegroundColor GreenWrite-Host " Thumbprint: $($cert.Thumbprint)" -ForegroundColor WhiteWrite-Host " Subject: $($cert.Subject)" -ForegroundColor White
# Verification - Test if private key is actually exportabletry { $exportPath = "$env:TEMP\TestExportableKey.pfx" $password = ConvertTo-SecureString -String "TestPassword123!" -Force -AsPlainText Export-PfxCertificate -Cert $cert -FilePath $exportPath -Password $password -Force | Out-Null Write-Host "✓ Private key export successful - key is exportable" -ForegroundColor Yellow Remove-Item $exportPath -Force -ErrorAction SilentlyContinue} catch { Write-Host "✗ Private key export failed: $($_.Exception.Message)" -ForegroundColor Red}
# Display certificate properties$certDetails = Get-Item -Path "Cert:\LocalMachine\My\$($cert.Thumbprint)"Write-Host "`n:fa-info-circle: Certificate Properties:" -ForegroundColor CyanWrite-Host " HasPrivateKey: $($certDetails.HasPrivateKey)" -ForegroundColor WhiteWrite-Host " KeyAlgorithm: $($certDetails.PublicKey.Key.KeySize)-bit $($certDetails.PublicKey.Oid.FriendlyName)" -ForegroundColor White
# Cleanup instructionWrite-Host "`n:fa-broom: Cleanup Command:" -ForegroundColor MagentaWrite-Host "Remove-Item 'Cert:\LocalMachine\My\$($cert.Thumbprint)' -Force" -ForegroundColor WhiteExpected Result - Scenario 2
Section titled “ Expected Result - Scenario 2”- State: ⚠️ Warning
- Detection: Private key is exportable (security risk)
- Alert: Exportable private key detected
Testing Scenario 3: Weak Key Length (1024-bit RSA)
Section titled “ Testing Scenario 3: Weak Key Length (1024-bit RSA)”Use Case: Test monitoring detection of certificates with weak cryptographic key lengths.
Scenario 3 Script
Section titled “ Scenario 3 Script”# Create certificate with weak 1024-bit RSA keyWrite-Host "Creating certificate with weak 1024-bit RSA key..." -ForegroundColor Cyan
$cert = New-SelfSignedCertificate ` -Subject "CN=TestCert-WeakKey, O=Nodinite Testing" ` -CertStoreLocation "Cert:\LocalMachine\My" ` -KeyLength 1024 ` -KeyAlgorithm RSA ` -HashAlgorithm SHA256 ` -KeyExportPolicy NonExportable ` -NotAfter (Get-Date).AddDays(90) ` -KeyUsage DigitalSignature, KeyEncipherment
Write-Host "✓ Certificate created with 1024-bit RSA key (weak)" -ForegroundColor YellowWrite-Host " Thumbprint: $($cert.Thumbprint)" -ForegroundColor WhiteWrite-Host " Subject: $($cert.Subject)" -ForegroundColor White
# Display key strength details$certDetails = Get-Item -Path "Cert:\LocalMachine\My\$($cert.Thumbprint)"Write-Host "`n:fa-shield-halved: Key Strength Analysis:" -ForegroundColor YellowWrite-Host " Algorithm: $($certDetails.PublicKey.Oid.FriendlyName)" -ForegroundColor WhiteWrite-Host " Key Size: $($certDetails.PublicKey.Key.KeySize) bits" -ForegroundColor RedWrite-Host " Security Level: WEAK (minimum recommended: 2048 bits)" -ForegroundColor RedWrite-Host " Hash Algorithm: $($certDetails.SignatureAlgorithm.FriendlyName)" -ForegroundColor White
# Additional security contextWrite-Host "`n:fa-info-circle: Security Context:" -ForegroundColor CyanWrite-Host " • 1024-bit RSA keys are deprecated by NIST (SP 800-57)" -ForegroundColor WhiteWrite-Host " • Industry standard minimum is 2048-bit RSA" -ForegroundColor WhiteWrite-Host " • This certificate should trigger a security warning" -ForegroundColor White
# Cleanup instructionWrite-Host "`n:fa-broom: Cleanup Command:" -ForegroundColor MagentaWrite-Host "Remove-Item 'Cert:\LocalMachine\My\$($cert.Thumbprint)' -Force" -ForegroundColor WhiteExpected Result - Scenario 3
Section titled “ Expected Result - Scenario 3”- State: ⚠️ Warning or ❌ Error (based on policy)
- Detection: Key length below security standards (< 2048 bits)
- Alert: Weak cryptographic key detected
Testing Scenario 4: Healthy Certificate (2048-bit Non-exportable RSA)
Section titled “ Testing Scenario 4: Healthy Certificate (2048-bit Non-exportable RSA)”Use Case: Test monitoring of a properly configured certificate that should show healthy status.
Scenario 4 Script
Section titled “ Scenario 4 Script”# Create secure certificate with best practicesWrite-Host "Creating healthy certificate with security best practices..." -ForegroundColor Cyan
$cert = New-SelfSignedCertificate ` -Subject "CN=TestCert-Healthy, O=Nodinite Testing" ` -CertStoreLocation "Cert:\LocalMachine\My" ` -KeyLength 2048 ` -KeyAlgorithm RSA ` -HashAlgorithm SHA256 ` -KeyExportPolicy NonExportable ` -NotAfter (Get-Date).AddDays(365) ` -KeyUsage DigitalSignature, KeyEncipherment ` -EnhancedKeyUsage "1.3.6.1.5.5.7.3.1" # Server Authentication
Write-Host "✓ Healthy certificate created successfully" -ForegroundColor GreenWrite-Host " Thumbprint: $($cert.Thumbprint)" -ForegroundColor WhiteWrite-Host " Subject: $($cert.Subject)" -ForegroundColor White
# Display security properties$certDetails = Get-Item -Path "Cert:\LocalMachine\My\$($cert.Thumbprint)"Write-Host "`n:fa-shield-check: Security Properties:" -ForegroundColor GreenWrite-Host " Algorithm: $($certDetails.PublicKey.Oid.FriendlyName)" -ForegroundColor WhiteWrite-Host " Key Size: $($certDetails.PublicKey.Key.KeySize) bits (Strong)" -ForegroundColor GreenWrite-Host " Hash Algorithm: $($certDetails.SignatureAlgorithm.FriendlyName)" -ForegroundColor WhiteWrite-Host " Private Key: $($certDetails.HasPrivateKey) (Non-exportable)" -ForegroundColor GreenWrite-Host " Valid Until: $($certDetails.NotAfter.ToString('yyyy-MM-dd'))" -ForegroundColor White
# Test private key accessibilitytry { $privateKey = [System.Security.Cryptography.X509Certificates.RSACertificateExtensions]::GetRSAPrivateKey($certDetails) if ($privateKey) { Write-Host " Private Key Access: ✓ Available and accessible" -ForegroundColor Green }} catch { Write-Host " Private Key Access: ✗ Error accessing private key" -ForegroundColor Red}
# Calculate days until expiration$daysUntilExpiry = ($certDetails.NotAfter - (Get-Date)).DaysWrite-Host "`n:fa-calendar-check: Expiration Status:" -ForegroundColor CyanWrite-Host " Days Until Expiry: $daysUntilExpiry days" -ForegroundColor Whiteif ($daysUntilExpiry -gt 90) { Write-Host " Status: ✓ Well within expiration threshold" -ForegroundColor Green} elseif ($daysUntilExpiry -gt 30) { Write-Host " Status: ⚠️ Approaching expiration (< 90 days)" -ForegroundColor Yellow} else { Write-Host " Status: ⚠️ Critical - Expires soon (< 30 days)" -ForegroundColor Red}
# Cleanup instructionWrite-Host "`n:fa-broom: Cleanup Command:" -ForegroundColor MagentaWrite-Host "Remove-Item 'Cert:\LocalMachine\My\$($cert.Thumbprint)' -Force" -ForegroundColor WhiteExpected Result - Scenario 4
Section titled “ Expected Result - Scenario 4”- State: ✅ OK
- Detection: Strong key, non-exportable, valid, not expiring soon
- Alert: No alerts (healthy certificate)
Testing Scenario 5: ECDSA Certificate with Strong Key
Section titled “ Testing Scenario 5: ECDSA Certificate with Strong Key”Use Case: Test monitoring of modern elliptic curve cryptography (ECDSA) certificates.
Scenario 5 Script
Section titled “ Scenario 5 Script”# Create ECDSA certificate with P-256 curve (256-bit equivalent)Write-Host "Creating ECDSA certificate with strong key..." -ForegroundColor Cyan
$cert = New-SelfSignedCertificate ` -Subject "CN=TestCert-ECDSA, O=Nodinite Testing" ` -CertStoreLocation "Cert:\LocalMachine\My" ` -KeyAlgorithm ECDSA_nistP256 ` -KeyExportPolicy NonExportable ` -HashAlgorithm SHA256 ` -NotAfter (Get-Date).AddDays(365) ` -KeyUsage DigitalSignature, KeyEncipherment
Write-Host "✓ ECDSA certificate created successfully" -ForegroundColor GreenWrite-Host " Thumbprint: $($cert.Thumbprint)" -ForegroundColor WhiteWrite-Host " Subject: $($cert.Subject)" -ForegroundColor White
# Display ECDSA-specific properties$certDetails = Get-Item -Path "Cert:\LocalMachine\My\$($cert.Thumbprint)"Write-Host "`n:fa-shield-check: ECDSA Properties:" -ForegroundColor GreenWrite-Host " Algorithm: $($certDetails.PublicKey.Oid.FriendlyName)" -ForegroundColor WhiteWrite-Host " Curve: P-256 (256-bit, equivalent to RSA 3072-bit)" -ForegroundColor GreenWrite-Host " Hash Algorithm: $($certDetails.SignatureAlgorithm.FriendlyName)" -ForegroundColor WhiteWrite-Host " Private Key: $($certDetails.HasPrivateKey) (Non-exportable)" -ForegroundColor Green
Write-Host "`n:fa-info-circle: ECDSA Advantages:" -ForegroundColor CyanWrite-Host " • Smaller key size with equivalent security to larger RSA keys" -ForegroundColor WhiteWrite-Host " • Faster cryptographic operations" -ForegroundColor WhiteWrite-Host " • Lower computational overhead" -ForegroundColor WhiteWrite-Host " • Increasingly common in modern TLS implementations" -ForegroundColor White
# Cleanup instructionWrite-Host "`n:fa-broom: Cleanup Command:" -ForegroundColor MagentaWrite-Host "Remove-Item 'Cert:\LocalMachine\My\$($cert.Thumbprint)' -Force" -ForegroundColor WhiteExpected Result - Scenario 5
Section titled “ Expected Result - Scenario 5”- State: ✅ OK
- Detection: Strong ECDSA key (P-256 curve), non-exportable, valid
- Alert: No alerts (modern cryptography properly configured)
Batch Testing Script
Section titled “ Batch Testing Script”Create all five test scenarios at once:
Complete Test Suite
Section titled “ Complete Test Suite”# Nodinite Certificate Testing SuiteWrite-Host "=== Nodinite Certificate Testing Suite ===" -ForegroundColor MagentaWrite-Host "Creating all four certificate testing scenarios..." -ForegroundColor Cyan
$certificates = @()
try { # Scenario 1: Certificate without private key Write-Host "`n1. Creating certificate without private key..." -ForegroundColor Yellow $cert1 = New-SelfSignedCertificate -Subject "CN=Test-NoPrivateKey" -CertStoreLocation "Cert:\LocalMachine\My" -KeyLength 2048 $exportPath = "$env:TEMP\TestCert-NoPrivateKey.cer" Export-Certificate -Cert $cert1 -FilePath $exportPath -Type CERT | Out-Null Remove-Item -Path "Cert:\LocalMachine\My\$($cert1.Thumbprint)" -Force $cert1Import = Import-Certificate -FilePath $exportPath -CertStoreLocation "Cert:\LocalMachine\My" $certificates += @{Name="No Private Key"; Thumbprint=$cert1Import.Thumbprint; Expected="Error"} Remove-Item $exportPath -Force
# Scenario 2: Exportable private key Write-Host "2. Creating certificate with exportable private key..." -ForegroundColor Yellow $cert2 = New-SelfSignedCertificate -Subject "CN=Test-ExportableKey" -CertStoreLocation "Cert:\LocalMachine\My" -KeyLength 2048 -KeyExportPolicy Exportable $certificates += @{Name="Exportable Key"; Thumbprint=$cert2.Thumbprint; Expected="Warning"}
# Scenario 3: Weak key length Write-Host "3. Creating certificate with weak 1024-bit key..." -ForegroundColor Yellow $cert3 = New-SelfSignedCertificate -Subject "CN=Test-WeakKey" -CertStoreLocation "Cert:\LocalMachine\My" -KeyLength 1024 -KeyExportPolicy NonExportable $certificates += @{Name="Weak Key (1024-bit)"; Thumbprint=$cert3.Thumbprint; Expected="Warning/Error"}
# Scenario 4: Healthy certificate Write-Host "4. Creating healthy certificate..." -ForegroundColor Yellow $cert4 = New-SelfSignedCertificate -Subject "CN=Test-Healthy" -CertStoreLocation "Cert:\LocalMachine\My" -KeyLength 2048 -KeyExportPolicy NonExportable -NotAfter (Get-Date).AddDays(365) $certificates += @{Name="Healthy Certificate"; Thumbprint=$cert4.Thumbprint; Expected="OK"}
# Summary Write-Host "`n=== Test Certificate Summary ===" -ForegroundColor Magenta foreach ($cert in $certificates) { Write-Host "$($cert.Name): $($cert.Thumbprint) (Expected: $($cert.Expected))" -ForegroundColor White }
Write-Host "`n:fa-rocket: Next Steps:" -ForegroundColor Cyan Write-Host "1. Configure Nodinite to monitor LocalMachine\My certificate store" -ForegroundColor White Write-Host "2. Wait for monitoring agent to discover certificates" -ForegroundColor White Write-Host "3. Verify each certificate shows expected monitoring state" -ForegroundColor White Write-Host "4. Test alert notifications for Warning/Error states" -ForegroundColor White
# Cleanup script Write-Host "`n:fa-broom: Cleanup All Test Certificates:" -ForegroundColor Magenta foreach ($cert in $certificates) { Write-Host "Remove-Item 'Cert:\LocalMachine\My\$($cert.Thumbprint)' -Force" -ForegroundColor Gray }
} catch { Write-Host "Error creating test certificates: $($_.Exception.Message)" -ForegroundColor Red}Usage Instructions
Section titled “ Usage Instructions”Running the Scripts
Section titled “ Running the Scripts”-
Open PowerShell 7 as Administrator
Terminal window # Ensure you're using PowerShell 7 and run as Administrator# Required for LocalMachine certificate store accessStart-Process pwsh -Verb RunAs# Verify PowerShell version$PSVersionTable.PSVersion # Should show 7.x.x or higher -
Run Individual Scenarios
- Copy and paste each scenario script
- Monitor the certificate in Nodinite interface
- Verify expected monitoring state
-
Run Complete Test Suite
- Use the batch script to create all scenarios
- Monitor all certificates simultaneously
- Compare actual vs expected results
Monitoring Verification
Section titled “ Monitoring Verification”After creating test certificates:
- Agent Discovery: Wait 1-2 minutes for monitoring agent to discover new certificates
- Monitor Views: Check certificate resources appear in Monitor Views
- State Verification: Confirm each certificate shows expected state (OK/Warning/Error)
- Alert Testing: Verify Warning/Error certificates trigger notifications
Cleanup
Section titled “ Cleanup”Always clean up test certificates after validation:
# Remove all test certificates (adjust thumbprints as needed)Get-ChildItem Cert:\LocalMachine\My|Where-Object {$_.Subject -like "*Test*"}|Remove-Item -ForceTroubleshooting
Section titled “ Troubleshooting”Common Issues
Section titled “Common Issues”Q: Certificate shows HasPrivateKey=True but monitoring reports missing private key
A: This can happen when the private key exists but is not accessible to the monitoring service account. Verify service account permissions to the private key.
Q: 1024-bit certificate doesn't trigger weak key warning
A: Check monitoring agent configuration for key strength policies. Some policies may be disabled by default.
Q: Exportable key detection not working
A: Exportable key detection requires specific permissions. Ensure monitoring service account can query certificate key properties.
Next Steps
Section titled “ Next Steps” Run PowerShell Scripts - Execute individual or batch testing scenarios
Verify Monitoring Results - Confirm expected certificate states in Nodinite
Clean Up Test Certificates - Remove test certificates after validation
Related Topics
Section titled “ Related Topics” Certificate Overview
Certificate Monitoring
Certificate Configuration
Private Key Health
FAQ: Certificates for gMSA Accounts