Skip to content

Commit c333d67

Browse files
authored
Create harden-ciphers.ps1
1 parent b5a7028 commit c333d67

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Ensure you're running as Administrator
2+
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole] "Administrator")) {
3+
Write-Host "❌ Please run this script as Administrator." -ForegroundColor Red
4+
exit
5+
}
6+
7+
Write-Host "🔐 Applying modern TLS 1.2 cipher suite policy..." -ForegroundColor Cyan
8+
9+
# Define modern and compatible cipher suites
10+
$modernSuites = @(
11+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
12+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
13+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
14+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
15+
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
16+
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
17+
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
18+
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
19+
"TLS_RSA_WITH_AES_256_GCM_SHA384",
20+
"TLS_RSA_WITH_AES_128_GCM_SHA256",
21+
"TLS_RSA_WITH_AES_256_CBC_SHA256",
22+
"TLS_RSA_WITH_AES_128_CBC_SHA256"
23+
) -join ','
24+
25+
# Create the policy registry key if it doesn't exist
26+
$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Cryptography\Configuration\SSL\00010002"
27+
New-Item -Path $regPath -Force | Out-Null
28+
29+
# Set the Functions (cipher suite order) value
30+
Set-ItemProperty -Path $regPath -Name "Functions" -Value $modernSuites
31+
32+
Write-Host "`n✅ Cipher suite policy successfully set." -ForegroundColor Green
33+
Write-Host "➡️ Location: HKLM:\SOFTWARE\Policies\Microsoft\Cryptography\Configuration\SSL\00010002"
34+
Write-Host "🛠️ You must reboot for changes to take effect." -ForegroundColor Yellow
35+
36+
# Offer immediate reboot
37+
$choice = Read-Host "`n🔁 Reboot now? (Y/N)"
38+
if ($choice -match '^[Yy]') {
39+
Write-Host "Rebooting..." -ForegroundColor Cyan
40+
shutdown /r /t 0
41+
} else {
42+
Write-Host "⚠️ Please reboot manually to apply changes." -ForegroundColor Yellow
43+
}

0 commit comments

Comments
 (0)