Skip to content

The remote certificate is invalid according to the validation procedure #2

@MelihAltintas

Description

@MelihAltintas

Hello,
hello I am getting certificate validation error while accessing from internal service in kubernetes cluster:
IDX20803: Unable to obtain configuration from: ****** System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors

I want to skip certificate validation. I tried this way: (But not work)

 .AddDynamicJwtBearer(JwtBearerDefaults.AuthenticationScheme, x =>
            {

                x.BackchannelHttpHandler = new HttpClientHandler()
                {
                    ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
                };

                x.Events = new JwtBearerEvents()
                {
                    OnAuthenticationFailed = context =>
                   {
                       context.Response.StatusCode = 401;
                       context.Response.ContentType = "application/json";


                       var result = JsonSerializer.Serialize(new { Message = context.Exception.GetType().Name.ToString(), Code = "401" });


                       context.Response.WriteAsync(result).Wait();
                       return Task.CompletedTask;
                   },
                    OnChallenge = context =>
                    {
                        context.HandleResponse();
                        return Task.CompletedTask;
                    }
                };
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateAudience = false,
                    ValidateIssuer = true,
                };
                x.RequireHttpsMetadata = false;
            }).AddDynamicAuthorityJwtBearerResolver<ResolveAuthorityService>();

Are there any way for skipping certificate validation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions