gpt4 book ai didi

wcf - 如何关闭 WCF 服务客户端的证书吊销?

转载 作者:行者123 更新时间:2023-12-04 07:15:01 24 4
gpt4 key购买 nike

如何关闭 WCF 服务客户端的证书吊销?
客户端代理由 wsdl.exe 生成并继承 SoapHttpClientProtocol。

最佳答案

我认为您正在寻找 ServicePointManager.ServerCertificateValidationCallback :

http://msdn.microsoft.com/en-gb/library/system.net.servicepointmanager.servercertificatevalidationcallback.aspx


其中需要一个 RemoteCertificateValidationCallback代表:

http://msdn.microsoft.com/en-gb/library/system.net.security.remotecertificatevalidationcallback.aspx


我以前从未处理过吊销的证书(我不得不处理其他问题,例如 SSL 过期),但我猜您只会执行以下操作:
class Program
{
static void Main(string[] args)
{
ServicePointManager.ServerCertificateValidationCallback +=
new RemoteCertificateValidationCallback(ValidateCertificate);

// Do WCF calls...
}

public static bool ValidateCertificate(object sender, X509Certificate cert,
X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
if(sslPolicyErrors == SslPolicyErrors.RemoteCertificateChainErrors)
{
foreach(X509ChainStatus chainStatus in chain.ChainStatus)
{
if(chainStatus.Status == X509ChainStatusFlags.Revoked)
{
return true;
}
}
}

/*
WARNING!

You should perform other cert validation checks here and not blindly
override your cert validation by returning true.

Otherwise the secure channel between your client and service
may not be secure.

*/

return false;
}
}

关于wcf - 如何关闭 WCF 服务客户端的证书吊销?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/204172/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com