.NET client connecting to ssl Web API

前端 未结 3 464
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:16

    Take a look at the C# Ignore certificate errors SO question. I believe you can add a certificate validation handler using ServicePointManager to circumvent certificate validation. It would probably be a good idea to use a signed certificate within your production environment though.

    ServicePointManager
        .ServerCertificateValidationCallback += 
        (sender, cert, chain, sslPolicyErrors) => true;
    

提交回复
热议问题