Skip to content

Commit

Permalink
analizators/s4830
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Dec 28, 2021
1 parent 352a8b6 commit 0a786bb
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 95 deletions.
3 changes: 0 additions & 3 deletions common/ASC.Core.Common/Notify/Senders/SmtpSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ private MailKit.Net.Smtp.SmtpClient GetSmtpClient()
{
Timeout = NETWORK_TIMEOUT
};

if (sslCertificatePermit)
smtpClient.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

return smtpClient;
}
Expand Down
10 changes: 1 addition & 9 deletions products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,15 +1177,7 @@ private File<T> CreateFileFromUri<T>(Folder<T> folder, string fileUri, string fi
file.Comment = FilesCommonResource.CommentCreate;

var request = new HttpRequestMessage();
request.RequestUri = new Uri(fileUri);

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}


request.RequestUri = new Uri(fileUri);

var fileDao = DaoFactory.GetFileDao<T>();
using var httpClient = new HttpClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,6 @@ private TrackResponse ProcessMailMerge<T>(T fileId, TrackerData fileData)
case MailMergeType.AttachPdf:
var requestDownload = new HttpRequestMessage();
requestDownload.RequestUri = new Uri(DocumentServiceConnector.ReplaceDocumentAdress(fileData.Url));

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}

using (var responseDownload = httpClient.Send(requestDownload))
using (var streamDownload = responseDownload.Content.ReadAsStream())
Expand Down Expand Up @@ -536,14 +530,7 @@ private TrackResponse ProcessMailMerge<T>(T fileId, TrackerData fileData)

case MailMergeType.Html:
var httpRequest = new HttpRequestMessage();
httpRequest.RequestUri = new Uri(DocumentServiceConnector.ReplaceDocumentAdress(fileData.Url));

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}

httpRequest.RequestUri = new Uri(DocumentServiceConnector.ReplaceDocumentAdress(fileData.Url));

using (var httpResponse = httpClient.Send(httpRequest))
using (var stream = httpResponse.Content.ReadAsStream())
Expand Down Expand Up @@ -609,13 +596,7 @@ private void StoringFileAfterError<T>(T fileId, string userId, string downloadUr

var store = GlobalStore.GetStore();
var request = new HttpRequestMessage();
request.RequestUri = new Uri(downloadUri);

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
request.RequestUri = new Uri(downloadUri);

using (var httpClient = new HttpClient())
using (var response = httpClient.Send(request))
Expand All @@ -642,13 +623,7 @@ private void SaveHistory<T>(File<T> file, string changes, string differenceUrl)
{
var fileDao = DaoFactory.GetFileDao<T>();
var request = new HttpRequestMessage();
request.RequestUri = new Uri(differenceUrl);

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
request.RequestUri = new Uri(differenceUrl);

using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
Expand Down
5 changes: 0 additions & 5 deletions products/ASC.Files/Core/Utils/EntryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,11 +1004,6 @@ public File<T> SaveEditing<T>(T fileId, string fileExtension, string downloadUri
}
else
{
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
var request = new HttpRequestMessage();
request.RequestUri = new Uri(downloadUri);

Expand Down
11 changes: 1 addition & 10 deletions products/ASC.Files/Core/Utils/FileConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,7 @@ public Stream Exec<T>(File<T> file, string toExtension)
var docKey = DocumentServiceHelper.GetDocKey(file);
fileUri = DocumentServiceConnector.ReplaceCommunityAdress(fileUri);
DocumentServiceConnector.GetConvertedUri(fileUri, file.ConvertedExtension, toExtension, docKey, null, null, null, false, out var convertUri);

if (WorkContext.IsMono && ServicePointManager.ServerCertificateValidationCallback == null)
{
ServicePointManager.ServerCertificateValidationCallback += (s, c, n, p) => true; //HACK: http://ubuntuforums.org/showthread.php?t=1841740
}

var request = new HttpRequestMessage();
request.RequestUri = new Uri(convertUri);

Expand Down Expand Up @@ -858,11 +854,6 @@ public File<T> SaveConvertedFile<T>(File<T> file, string convertedFileUrl)

using var httpClient = new HttpClient();

if (WorkContext.IsMono && ServicePointManager.ServerCertificateValidationCallback == null)
{
ServicePointManager.ServerCertificateValidationCallback += (s, c, n, p) => true; //HACK: http://ubuntuforums.org/showthread.php?t=1841740
}

try
{
using var response = httpClient.Send(request);
Expand Down
6 changes: 0 additions & 6 deletions products/ASC.Files/Core/Utils/MailMergeTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ private string AttachToMail(MailMergeTask mailMergeTask)
request.Headers.Add("Content-Type", MimeMapping.GetMimeMapping(mailMergeTask.AttachTitle));
request.Content = new StreamContent(mailMergeTask.Attach);

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}

string responseAttachString;
using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
Expand Down
6 changes: 0 additions & 6 deletions products/ASC.Files/Server/Helpers/FilesControllerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,6 @@ public object CreateUploadSession(T folderId, string fileName, long fileSize, st
request.Headers.Add(HttpRequestExtensions.UrlRewriterHeader, rewriterHeader.ToString());
}

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}

using var response = httpClient.Send(request);
using var responseStream = response.Content.ReadAsStream();
using var streamReader = new StreamReader(responseStream);
Expand Down
8 changes: 1 addition & 7 deletions products/ASC.Files/Service/Thumbnail/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,7 @@ private void SaveThumbnail(IFileDao<T> fileDao, File<T> file, string thumbnailUr
logger.DebugFormat("SaveThumbnail: FileId: {0}. ThumbnailUrl {1}.", file.ID, thumbnailUrl);

var request = new HttpRequestMessage();
request.RequestUri = new Uri(thumbnailUrl);

//HACK: http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono && ServicePointManager.ServerCertificateValidationCallback == null)
{
ServicePointManager.ServerCertificateValidationCallback += (s, c, n, p) => true;
}
request.RequestUri = new Uri(thumbnailUrl);

using var httpClient = new HttpClient();
using var response = httpClient.Send(request);
Expand Down
3 changes: 0 additions & 3 deletions web/ASC.Web.Api/Models/Smtp/SmtpOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ public SmtpClient GetSmtpClient()
Timeout = (int)TimeSpan.FromSeconds(30).TotalMilliseconds
};

if (sslCertificatePermit)
client.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;

return client;
}

Expand Down
18 changes: 0 additions & 18 deletions web/ASC.Web.Core/Files/DocumentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,6 @@ public static int GetConvertedUri(

request.Content = new StringContent(bodyString, Encoding.UTF8, "application/json");

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}

string dataResponse;
HttpResponseMessage response = null;
Stream responseStream = null;
Expand Down Expand Up @@ -279,12 +273,6 @@ public static CommandResultTypes CommandRequest(FileUtility fileUtility,

request.Content = new StringContent(bodyString, Encoding.UTF8, "application/json");

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}

string dataResponse;
using (var response = httpClient.Send(request))
using (var stream = response.Content.ReadAsStream())
Expand Down Expand Up @@ -361,12 +349,6 @@ public static string DocbuilderRequest(

request.Content = new StringContent(bodyString, Encoding.UTF8, "application/json");

// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (WorkContext.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}

string dataResponse = null;

using (var response = httpClient.Send(request))
Expand Down

0 comments on commit 0a786bb

Please sign in to comment.