By default, WinRM requires mutual authentication and strict cryptographic verification when operating over HTTPS. For a successful connection, the certificate used must explicitly allow Client Authentication 在它内 Enhanced Key Usage (EKU) 如果此属性缺失,或者只包含"服务器身份验证",Windows将拒绝连接以防止未经授权的访问或中间人攻击.
逐步修复问题
To resolve this issue, you must ensure that the certificate being used contains the Client Authentication 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 标识符: 1.3.6.1.5.5.7.3.2 下面是两种最常见的解决方法.
方法1:使用正确的EKU申请新证书 (建议)
如果您使用内部 Active Directory 证书服务 (AD CS) 或其他证书授权机构 (CA),则必须发出包含服务器和客户端认证的证书.
- 打开门 Run 通过按下对话框 Windows Key + R.
- 它们的类型
mmc然后按下. Enter 打开微软管理控制台. - 点击 File 在顶部菜单中,然后选择 Add/Remove Snap-in....
- 选择 Certificates 在左边的列表中点击 Add.
- 选择一个. Computer account 按一下 Next 选择 Local computer 然后点击 Finish 按一下 OK 关闭插入窗口.
- 扩大 Certificates (Local Computer) 没有. Personal 没有. Certificates.
- 在中间窗口中右键单击一个空白空间,选择 All Tasks 然后点击 Request New Certificate....
- 点击 Next 通过向导,直到您看到组织的证书模板.
- 选择包含两者的模板 Server Authentication 这里是我的家. Client Authentication (例如默认的"计算机"模板).
- 点击 Enroll 然后 Finish.
方法2:配置 WinRM HTTPS 收听器使用新证书
一旦您生成有效证书,您必须通过将其特定的指纹链接到WinRM服务来配置WinRM来使用它.
- 在同一个
mmc双击您新注册的证书. Personal 没有. Certificates. - 让我们去看看. Details 标签,向下滚动到底部,然后点击 Thumbprint.
- 从框中复制十六进制字符串 (例如,
a1b2c3d4e5...删除字母和数字之间的任何空格,从而形成一个连续的字符串. - 打开Windows开始菜单,搜索 Command Prompt,右键点击它,并选择 Run as administrator.
- Delete the existing broken WinRM HTTPS listener by typing the following command and pressing Enter:
winrm delete winrm/config/Listener?Address=*+Transport=HTTPS - Create the new listener utilizing your corrected certificate thumbprint by running this command (replace
YOUR_CERTIFICATE_THUMBPRINT在步骤3中复制的清洁字符串):winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="YOUR_COMPUTER_FQDN";CertificateThumbprint="YOUR_CERTIFICATE_THUMBPRINT"} - 重新启动 WinRM 服务以立即应用所有修改,运行:
net stop winrm && net start winrm
方法3:暂时禁用客户端证书验证 (解决方案)
If you cannot immediately issue a new certificate and need to restore remote management urgency, you can configure the WinRM service to bypass the client certificate EKU validation requirement. Note: This lowers deployment security and should only be used as a temporary solution.
- 打开Windows开始菜单,搜索 PowerShell,右键点击它,并选择 Run as administrator.
- 运行下列命令来检查您当前的客户端证书验证设置:
Get-ChildItem WSMan:\localhost\Service\Auth - 通过修改WSMan配置来禁用有效客户端证书的要求:
Set-Item WSMan:\localhost\Service\Auth\Certificate -Value $false - 如果您正在从客户机连接,您可能还需要指示客户端在过渡期内忽略验证失败:
Set-Item WSMan:\localhost\Client\Auth\Certificate -Value $false - 使用PowerShell重新启动WinRM服务以确保更改生效:
Restart-Service winrm
可能有一些错误.. Learn Microsoft