Move Serurity protocol changer

This commit is contained in:
Sergey Chebotar 2022-12-20 12:58:30 +03:00
parent 64d0abd006
commit a9ffc5510d
3 changed files with 8 additions and 5 deletions

View File

@ -2,6 +2,7 @@
using ExcelDna.IntelliSense;
using Microsoft.Office.Interop.Excel;
using RhSolutions.Services;
using System.Net;
using System.Net.Http;
namespace RhSolutions.AddIn
@ -18,6 +19,11 @@ namespace RhSolutions.AddIn
IntelliSenseServer.Install();
RegistryUtil.Initialize();
EventsUtil.Initialize();
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls;
}
public void AutoClose()

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<DnaLibrary Name="RhSolutions Add-In" RuntimeVersion="v4.0" xmlns="http://schemas.excel-dna.net/addin/2020/07/dnalibrary">
<ExternalLibrary Path="RhSolutions.AddIn.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" IncludePdb="false" />
<Reference Path="ExcelDna.IntelliSense.dll" Pack="true" />
<Reference Path="Newtonsoft.Json.dll" Pack="true" />
<!--
The RuntimeVersion attribute above allows only the following setting:

View File

@ -16,11 +16,6 @@ namespace RhSolutions.Services
{
string request = @"https://rh.cebotari.ru/api/search?query=" + line;
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12 |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls;
string response = await httpClient.GetStringAsync(request);
var products = JsonConvert.DeserializeObject<IEnumerable<DbProduct>>(response);