Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could Not create ssl/tls secure channel. Html Agility

I am trying to scrape a site using HTML Agility Pack. The site is using https and it shows the error on this line

doc = web.Load(url);

I am creating a desktop application not a web application.

like image 893
Faisal Avatar asked Mar 08 '23 09:03

Faisal


1 Answers

You need to enable the correct protocol type on the service point manager. Just add it before the line you said caused the error. This should do it.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
doc = web.Load(url);
like image 71
CodingKuma Avatar answered Mar 21 '23 11:03

CodingKuma