Where to place RemoteCertificateValidationCallback?

后端 未结 3 1455
忘了有多久
忘了有多久 2020-12-20 05:59

I have the same problem as here: How to disable "Security Alert" window in Webbrowser control

I like the answer, but where am I going to place the Se

3条回答
  •  一个人的身影
    2020-12-20 06:53

    You should put the following at any point before you show the web browser control / submit the page:

    ServicePointManager.ServerCertificateValidationCallback += 
        new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });
    

    (This is exactly the same as the example answer in the linked question, but the callback method is anonymous so its a little more compact).

提交回复
热议问题