65
65
param ( $restart)
66
66
$subkeys = Get-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL"
67
67
$ciphers = $subkeys.OpenSubKey("Ciphers", $true)
68
+
68
69
if($ciphers.SubKeyCount -eq 0) {
69
70
$k1 = $ciphers.CreateSubKey("RC4 128/128")
70
71
$k1.SetValue("Enabled", 0, [Microsoft.Win32.RegistryValueKind]::DWord)
@@ -103,7 +104,9 @@ Function Set-CryptoSetting {
103
104
New-ItemProperty -Path $regkeys[$keyindex] -Name $value -Value $valuedata -PropertyType $valuetype | Out-Null
104
105
$restart = $True
105
106
Write-Host "Configuring $regkeys[$keyindex]...."
107
+
106
108
} Else {
109
+
107
110
# Value does exist - if not equal to desired value, change it
108
111
If ($val -ne $valuedata) {
109
112
Set-ItemProperty -Path $regkeys[$keyindex] -Name $value -Value $valuedata
@@ -149,7 +152,9 @@ Function Set-Windows10PlusCurveOrder {
149
152
if( $null -eq $val) {
150
153
New-ItemProperty -Path $regkeys[15] -Name EccCurves -Value $desiredOrder -PropertyType MultiString | Out-Null
151
154
$reboot = $True
155
+
152
156
} else {
157
+
153
158
if ([System.String]::Join(';', $val) -ne [System.String]::Join(';', $desiredOrder)) {
154
159
Write-Host "The original curve order ", `n, $val, `n, "needs to be updated to ", $desiredOrder
155
160
Set-ItemProperty -Path $regkeys[15] -Name EccCurves -Value $desiredOrder
@@ -159,6 +164,7 @@ Function Set-Windows10PlusCurveOrder {
159
164
}
160
165
161
166
$reboot
167
+
162
168
}
163
169
164
170
If ([Environment]::OSVersion.Version.Major -lt 10) {
@@ -188,19 +194,15 @@ If ([Environment]::OSVersion.Version.Major -lt 10) {
188
194
}
189
195
190
196
# If any settings are changed, this will change to $True and the server will reboot
191
-
192
197
$reboot = $False
193
198
194
199
# Check for existence of registry keys (SSL 2.0, SSL 3.0, TLS 1.0, TLS 1.1, TLS 1.2), and create if they do not exist
195
-
196
200
For ($i = 0; $i -le 14; $i = $i + 1) {
197
201
If (!(Test-Path -Path $regkeys[$i])) {
198
202
New-Item $regkeys[$i] | Out-Null
199
203
}
200
204
}
201
205
202
- ####################################################
203
-
204
206
# Ensure SSL 2.0 disabled for client/server
205
207
$reboot = Set-CryptoSetting 10 DisabledByDefault 1 DWord $reboot
206
208
$reboot = Set-CryptoSetting 10 Enabled 0 DWord $reboot
@@ -231,8 +233,6 @@ $reboot = Set-CryptoSetting 7 Enabled 1 DWord $reboot
231
233
$reboot = Set-CryptoSetting 8 DisabledByDefault 0 DWord $reboot
232
234
$reboot = Set-CryptoSetting 8 Enabled 1 DWord $reboot
233
235
234
- ####################################################
235
-
236
236
$reboot = DisableRC4($reboot)
237
237
238
238
If ($SetCipherOrder) {
@@ -253,40 +253,46 @@ If ($SetCipherOrder) {
253
253
254
254
$reboot = Set-Windows10PlusCurveOrder $reboot
255
255
256
- # If any settings were changed, reboot
257
- # If any settings were changed, reboot
258
- If ($reboot)
259
- {
260
- Write-Host "Rebooting now..."
261
- Write-Host "Using this command: shutdown.exe /r /t 5 /c ""Crypto settings changed"" /f /d p:2:4 "
262
- shutdown.exe /r /t 5 /c "Crypto settings changed" /f /d p:2:4
263
- }
264
- Else
265
- {
266
- Write-Host "Nothing get updated."
267
- }
268
-
269
-
270
- <# If ($reboot) {
256
+ If ($reboot) {
271
257
# Randomize the reboot timing since it could be run in a large cluster.
272
258
$tick = [System.Int32]([System.DateTime]::Now.Ticks % [System.Int32]::MaxValue)
273
259
$rand = [System.Random]::new($tick)
274
260
$sec = $rand.Next(30, 600)
275
261
Write-Host "Rebooting after", $sec, " second(s)..."
276
- Write-Host shutdown.exe /r /t $sec /c "Crypto settings changed" /f /d p:2:4
262
+ Write-Host "shutdown.exe /r /t $sec /c ""Crypto settings changed"" /f /d p:2:4"
263
+ shutdown.exe /r /t $sec /c "Crypto settings changed" /f /d p:2:4
264
+
277
265
} Else {
266
+
278
267
Write-Host "Nothing get updated."
279
- } #>
268
+ }
280
269
```
281
270
282
271
## Step 2: Create a command file
283
272
284
273
Create a CMD file named ** RunTLSSettings.cmd** using the below. Store this script on your local desktop for easy access in later steps.
285
274
286
275
``` cmd
287
- PowerShell -ExecutionPolicy Unrestricted %~dp0TLSsettings.ps1
288
- REM This line is required to ensure the startup tasks does not block the role from starting in case of error. DO NOT REMOVE!!!!
289
- EXIT /B 0
276
+ SET LOG_FILE="%TEMP%\StartupLog.txt"
277
+ SET EXECUTE_PS1=0
278
+
279
+ IF "%ComputeEmulatorRunning%" == "" (
280
+ SET EXECUTE_PS1=1
281
+ )
282
+
283
+ IF "%ComputeEmulatorRunning%" == "false" (
284
+ SET EXECUTE_PS1=1
285
+ )
286
+
287
+ IF %EXECUTE_PS1% EQU 1 (
288
+ echo "Invoking SSLConfigure.ps1 on Azure service at %TIME% on %DATE%" >> %LOG_FILE% 2>&1
289
+ PowerShell -ExecutionPolicy Unrestricted %~dp0SSLConfigure.ps1 -sco >> %LOG_FILE% 2>&1
290
+ ) ELSE (
291
+ echo "Skipping SSLConfigure.ps1 invocation on emulated environment" >> %LOG_FILE% 2>&1
292
+ )
293
+
294
+ EXIT /B %ERRORLEVEL%
295
+
290
296
```
291
297
292
298
## Step 3: Add the startup task to the role’s service definition (csdef)
0 commit comments