Skip to content

Commit

Permalink
Disabled HTTP cetrificates validation for dependency injection factory;
Browse files Browse the repository at this point in the history
  • Loading branch information
k-karuna committed Nov 7, 2022
1 parent 715c284 commit 06b1d74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions Matrix.Sdk/MatrixClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ public class SingletonHttpFactory : IHttpClientFactory
{
private readonly HttpClient _httpClient;

public static HttpClientHandler GetHttpHandler() => new HttpClientHandler
{ ServerCertificateCustomValidationCallback = (_, _, _, _) => true };

public SingletonHttpFactory()
{
var httpClientHandler = new HttpClientHandler
{ ServerCertificateCustomValidationCallback = (_, _, _, _) => true };
_httpClient = new HttpClient(httpClientHandler);
var httpClientHandler =
_httpClient = new HttpClient(GetHttpHandler());
}

public HttpClient CreateClient(string name) => _httpClient;
Expand Down
14 changes: 7 additions & 7 deletions Matrix.Sdk/MatrixClientServiceExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Net.Http;

namespace Matrix.Sdk
{
using System.Collections.Generic;
using Core;
using Core.Domain.RoomEvent;
using Core.Domain.Services;
using Core.Infrastructure.Services;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -15,14 +14,15 @@ public static class MatrixClientServiceExtensions
{
public static IServiceCollection AddMatrixClient(this IServiceCollection services)
{
services.AddHttpClient();

services.AddHttpClient(Constants.Matrix)
.ConfigurePrimaryHttpMessageHandler(SingletonHttpFactory.GetHttpHandler);

services.AddSingleton<ClientService>();

services.AddSingleton<EventService>();
services.AddSingleton<RoomService>();
services.AddSingleton<UserService>();

services.AddTransient<IPollingService, PollingService>();
services.AddTransient<IMatrixClient, MatrixClient>();

Expand Down

0 comments on commit 06b1d74

Please sign in to comment.