csharp: ignore certificate in config

This commit is contained in:
Olga Larinova
2022-03-24 10:26:31 +03:00
parent 60469b0dba
commit ef4e283804
4 changed files with 22 additions and 16 deletions

View File

@ -354,9 +354,9 @@ namespace OnlineEditorsExample
try
{
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (IsMono)
{
if(!WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
using (var stream = req.GetResponse().GetResponseStream()) // get response stream of the uploading file
@ -421,9 +421,9 @@ namespace OnlineEditorsExample
var req = (HttpWebRequest)WebRequest.Create(fileUrl);
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (IsMono)
{
if(!WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
using (var stream = req.GetResponse().GetResponseStream())
@ -509,9 +509,9 @@ namespace OnlineEditorsExample
var req = (HttpWebRequest)WebRequest.Create(newFileUri);
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (IsMono)
{
if(!WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
using (var stream = req.GetResponse().GetResponseStream()) // get response stream of the converting file

View File

@ -146,9 +146,9 @@ namespace ASC.Api.DocumentConverter
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
if(!WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
string dataResponse;

View File

@ -131,9 +131,9 @@ namespace OnlineEditorsExample
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
if(!WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
var storagePath = _Default.StoragePath(newFileName, userAddress); // get the file path
@ -212,9 +212,9 @@ namespace OnlineEditorsExample
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
if(!WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
string forcesavePath = "";
@ -262,6 +262,11 @@ namespace OnlineEditorsExample
// create a command request
public static void commandRequest(string method, string key, object meta = null)
{
if(!WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
string documentCommandUrl = WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.command"];
var request = (HttpWebRequest)WebRequest.Create(documentCommandUrl);
@ -282,9 +287,9 @@ namespace OnlineEditorsExample
if (JwtManager.Enabled)
{
var payload = new Dictionary<string, object>
{
{ "payload", body }
};
{
{ "payload", body }
};
var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token
var bodyToken = JwtManager.Encode(body); // encode body into a body token

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<clear />
<add key="version" value="1.1.0"/>
@ -13,6 +13,7 @@
<add key="files.docservice.timeout" value="120000" />
<add key="files.docservice.secret" value="" />
<add key="files.docservice.header" value="Authorization" />
<add key="files.docservice.verify-peer-off" value="true"/>
<add key="files.docservice.url.site" value="http://documentserver/"/>