与的精确复制
SSL error RemoteCertificateNameMismatch
SSL error RemoteCertificateNameMismatch
我使用WCF为客户端访问服务。我正在尝试使用TLS (https)访问端点。我有私钥和公钥的证书。
如果我有服务的端点,主机名与证书名(“已发到”)相同,那么我就可以从客户端访问该服务。
如果“向”发出的域名和端点域名的名称不同,则错误“无法为SSL/TLS安全通道建立信任关系”。我已将证书添加到“受信任的根”、“个人”和“受信任的人”。在我的服务中,我使用了"PeerOrChainTrust“。
如果有人知道这件事,请告诉我。
发布于 2009-02-20 12:40:56
在这种情况下,您需要为客户端的服务器定义信任策略,
在调用服务之前,只需调用SetCertPolicy一次。
using System.Net;
using System.Security.Cryptography.X509Certificates;
public static void SetCertPolicy()
{
ServicePointManager.ServerCertificateValidationCallback += RemoteCertValidate;
}
private static bool RemoteCertValidate( object sender, X509Certificate cert, X509Chain chain,
SslPolicyErrors error )
{
// trust any cert!!!
return true;
}https://stackoverflow.com/questions/569413
复制相似问题