开发人员技术 | .NET | 其他
基于 .NET 软件框架的 Microsoft 技术。 不属于特定类别的其他主题。
在 PowerShell 文档页面:
https://learn.microsoft.com/en-us/powershell/module/pki/test-certificate?view=windowsserver2025-ps
示例 1 中的命令为:
Get-ChildItem -Path Cert:\LocalMachine\My | Test-Certificate -Policy SSL -DNSName 'dns=contoso.com'
但实际运行会报错:“证书的 CN 名与传递的值不匹配”。
正确写法应为:
-DnsName 'contoso.com'
因为 Test-Certificate 的 -DnsName 参数只接受纯主机名,'dns=' 是 certreq.inf 文件的语法,不应出现在 PowerShell 示例中。
建议修正该示例,避免误导用户。