问题描述
我们有一个 powershell 脚本,用作客户客户端的启动脚本,用于获取机器信息。
重要的部分是下面的摘录:
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint,X509Certificate cert,WebRequest request,int policyErrors) {
var hexaVal = Convert.ToString(policyErrors,16).ToUpper();
var hrEx = Marshal.GetExceptionForHR(policyErrors);
System.Console.WriteLine("cert hash: [{0}],problem: [{1}],win32ErrorHexaVal: [{2}],win32ErrorMsg: [{3}]",cert.GetCertHashString(),policyErrors,hexaVal,hrEx.Message);
if (policyErrors == 0)
{
return true;
}
if (cert.GetCertHashString() == "fictitiousHash1"
|| cert.GetCertHashString() == "fictitiousHash2")
{
return true;
}
return false;
}
}
"@
}
我在其中嵌入了 C#
代码以验证使用 Invoke-RestMethod ($myUrl) -Method 'POST' -Headers $headers -Body $body
执行的 http 请求
我希望所有计算机都打印相同的证书哈希 - 据我所知,它驻留在服务器中,这意味着所有请求都应该相同。这就是发生的情况,除了一台计算机打印不同的哈希值。
我在 string.Format
中添加了额外的参数,试图弄清楚这会如何/为什么会发生。
无济于事。 还是没有头绪。
有人可以帮忙吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)