.NET client connecting to ssl Web API

前端 未结 3 460
Happy的楠姐
Happy的楠姐 2020-12-24 02:27

I have a ASP.NET Web API which I\'d like to use with ssl. Currently the server is using a self-signed cert, and at this moment both http and https are allowed. I have a very

3条回答
  •  执笔经年
    2020-12-24 03:12

    This worked for me. Just add the following before the call to GetAsync.

    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
    

    This will ignore the SSL errors. This is only recommended in an intranet environment or other closed network where server identities can't be forged.

提交回复
热议问题