RusKnyaz / Optimus

Optimus is headless Web Browser fully implemented on .net.
MIT License
82 stars 8 forks source link

WebException: The request was aborted: Could not create SSL/TLS secure channel. #34

Closed ThunderCls closed 3 years ago

ThunderCls commented 4 years ago

Apparently there are some issues when trying to access websites with https. My code is:

var engine = EngineBuilder.New()
                     .UseJint()// Enable JavaScripts execution.
                     .Build(); // Builds the Optimus engine.

//Request the web page.
var page = await engine.OpenUrl(https://www.mysite.com);

When executing OpenUrl() I get the exception "WebException: The request was aborted: Could not create SSL/TLS secure channel."

Even if I add the lines

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Then I get a deadlock

Any thoughts or workarounds for this?

RusKnyaz commented 4 years ago

Hm. What is your OS?

ThunderCls commented 4 years ago

Oh I forgot to mention, I’m using VS2017 in W10 x64

RusKnyaz commented 3 years ago

You should configure httpClientHandler with own certificate validation method:


var engine = EngineBuilder.New()
    .ConfigureResourceProvider(res => res.Http(h => h.ConfigureClientHandler(c => 
        c.ServerCertificateCustomValidationCallback = (a1, a2, a3, a4) => true)))
    .Build();
`