none
UWP HttpClient 访问Https 如何忽略证书获取数据? RRS feed

  • 问题

  •  

    UWP HttpClient 访问Https 如何忽略证书获取数据?

    百度了好多,C#这类的很少 基本是java的

    再不就是以前的ServicePointManager 但UWP里没有~ 急求

    2017年2月9日 4:50

全部回复

  • 您好 liujiawei,

    你可以用HttpBaseProtocolFilter去实例化HttpClient.

    var filter = new HttpBaseProtocolFilter();
    #if DEBUG
                filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Expired);
                filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
                filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);
    #endif
                using (var httpClient = new HttpClient(filter))
                {
    
                }


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    2017年2月9日 6:45
    版主