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 06b1d74 commit bbda578
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Matrix.Sdk/Matrix.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Authors>Mikhail Tatarenko</Authors>
<Product>Matrix.Sdk</Product>
<Description>This open-source library allows you to build .NET apps compatible with Matrix Protocol - http://www.matrix.org.</Description>
<Version>1.0.6</Version>
<Version>1.0.7</Version>
<Copyright>Copyright © Baking Bad 2019-2022</Copyright>
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down
8 changes: 3 additions & 5 deletions Matrix.Sdk/MatrixClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ public class SingletonHttpFactory : IHttpClientFactory
{
private readonly HttpClient _httpClient;

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

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

public HttpClient CreateClient(string name) => _httpClient;
Expand Down
4 changes: 1 addition & 3 deletions Matrix.Sdk/MatrixClientServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ public static class MatrixClientServiceExtensions
{
public static IServiceCollection AddMatrixClient(this IServiceCollection services)
{
services.AddHttpClient(Constants.Matrix)
.ConfigurePrimaryHttpMessageHandler(SingletonHttpFactory.GetHttpHandler);
services.AddSingleton<IHttpClientFactory, SingletonHttpFactory>();

services.AddSingleton<ClientService>();

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

0 comments on commit bbda578

Please sign in to comment.