How to accept a self-signed SSL certificate in a WCF client?

后端 未结 2 921
礼貌的吻别
礼貌的吻别 2021-01-11 17:15

This may be a stupid question but I just can\'t find the answer.

What I would like to do: I have a WCF service hosted by IIS. It is working perfectly, I can access t

2条回答
  •  爱一瞬间的悲伤
    2021-01-11 17:44

    You can register the certificate yourself. If load the certificate in the client as well, and then register the it as trusted you shouldn't get that warning.

    You need to find a X509CertificateCollection and add the certificate to that collection. I had this kind of problem with a SmtpClient running over Ssl.

    By hooking the System.Net.ServicePointManager.ServerCertificateValidationCallback or implementing System.Net.ICertificatePolicy and identify my own installed certificate as valid/trusted (attached to the System.Net.ServicePointManager.CertificatePolicy).

    This is not WCF stuff per se, but from what I could tell, this should translate to WCF as well. It all depends what WCF is uses under the hood.

提交回复
热议问题