Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MelihAltintas opened this issue Feb 8, 2022 · 0 comments

Comments

@MelihAltintas
Copy link

MelihAltintas commented Feb 8, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant