我在使用 Powershell 脚本时遇到的问题是需要修改的键包含正斜杠,而 Powershell 将其视为路径分隔符,脚本失败。
解决方案是创建一个控制台应用程序并将其设置为在启动时运行:
class Program
{
static void Main(string[] args)
{
string[] subKeys = new string[]
{
"RC4 40/128",
"RC4 56/128",
"RC4 64/128",
"RC4 128/128",
};
RegistryKey parentKey = Registry.LocalMachine.OpenSubKey(
@"SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers", true);
foreach (string keyName in subKeys)
{
var newKey = parentKey.CreateSubKey(keyName);
newKey.SetValue("Enabled", 0);
newKey.Close();
}
parentKey.Close();
}
}
将输出文件(在我的情况下为 DisableRc4.exe)复制到 webrole 的根目录并设置为 始终复制
创建一个包含 DisableRc4.cmd 的文件
.\DisableRc4.exe
EXIT /B 0
为您的 Web 角色更新 ServiceDefinition.csdef,如下所示
<Startup>
<Task commandLine="DisableRc4.cmd" executionContext="elevated" taskType="simple" />
</Startup>
我已使用https://www.ssllabs.com/ssltest/index.html 验证已删除 RC4 支持
启动前修改
之后