Skip to content

The certificate authority is invalid or incorrect exception while using .NET standard 2.0 #24248

@Petermarcu

Description

@Petermarcu

@jainankit2474 commented on Sun Nov 26 2017

My problem here is specifically in .Net standard 2.0 and .Net core 2.0, since the same code, seems to work fine with .net framework 4.6.1.

In .NET framework, we are using following code to trust all certificates:

ServicePointManager.ServiceCertificateValidationCallback += (o, c, ch, er) => true;

But the same code is not working with .NET core 2.0 and .NET standard 2.0.

I have also tried the below code:

var httpClientHandler = new HttpClientHandler(); httpClientHandler.ServiceCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;

But this is not working for me.
'An error occurred while sending the request, The certificate authority is invalid or incorrect' exception has been thrown.

image

Please suggest me any alternative solution for the self-signed certificate in .NET standard 2.0.


@Petermarcu commented on Sun Nov 26 2017

This may be an issue with the implementation of those API's in .NET Core 2.0. I'm going to move this issue to .NET Core so that can be determined.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions