Discovery icon indicating copy to clipboard operation
Discovery copied to clipboard

Getting this error Peer certificate cannot be authenticated with given CA certificate

Open gsainagendraprasad opened this issue 9 years ago • 7 comments

Hi , I am trying to see how Service Discovery works in PCF Dev. I logged in to pcf dev using cf login -a https://api.local.pcfdev.io --skip-ssl-validation and published both my client and service applications. when i call the client url , i am getting HTTP 500 error, when i saw the logs it says -

2017-04-28T17:26:01.50-0500 [APP/PROC/WEB/0] OUT fail: Steeltoe.Discovery.Eureka.Transport.EurekaHttpClient[0] 2017-04-28T17:26:01.50-0500 [APP/PROC/WEB/0] OUT DoGetApplicationsAsync Exception: System.Net.Http.HttpRequestExce ption: An error occurred while sending the request. ---> System.Net.Http.CurlException: Peer certificate cannot be authe nticated with given CA certificates

please help me on this error:

As I was reading through : http://steeltoe.io/docs/steeltoe-discovery/#1-2-2-1-settings-to-discover this they are saying i may run into ssl certificate issues, is this error related with this ??

gsainagendraprasad avatar May 01 '17 14:05 gsainagendraprasad

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/144613435

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar May 01 '17 14:05 cf-gitbot

Yes, you will need to disable certificate validation when running on PCF Dev.

dtillman avatar May 01 '17 16:05 dtillman

I did it using this --skip-ssl-validation while logging in to pcf dev. Still my client is unable to discover the registered service.

Here is my class :+1:

public class ServiceDiscoveryService : IServiceDiscoveryService { DiscoveryHttpClientHandler _handler; private ILogger _logger;

    private const string RANDOM_FORTUNE_URL = "http://ServiceDiscoveryService/api/values";

    public ServiceDiscoveryService(IDiscoveryClient client, ILogger<ServiceDiscoveryService> logger)
    {
        _handler = new DiscoveryHttpClientHandler(client);

        _logger = logger;
    }

    public  string RandomFortuneAsync()
    {
        _logger?.LogInformation("Before Calling GetClient");
        var client = GetClient();
        _logger?.LogInformation("After Calling GetClient");
        return  (client.GetAsync(RANDOM_FORTUNE_URL).Result).Content.ReadAsStringAsync().Result;
    }

    private HttpClient GetClient()
    {
        var client = new HttpClient(_handler, false);
        return client;
    }
}

gsainagendraprasad avatar May 01 '17 16:05 gsainagendraprasad

In your appsettings.json files(s), add eureka:client:validate_certificates => false, the default is true if not specified.

dtillman avatar May 01 '17 16:05 dtillman

@dtillman , I will try this settings and will let you know either way.Thank you.

gsainagendraprasad avatar May 01 '17 16:05 gsainagendraprasad

@dtillman, It Worked, my client application is able to call service and fetch data. Thank you.

gsainagendraprasad avatar May 01 '17 16:05 gsainagendraprasad

@dtillman , Quick question, What about if a service has multiple versions , how should they get registered in to eureka ?? If spring-application-name is same for all versions then how do we make sure client application is consuming the appropriate version of service ??

gsainagendraprasad avatar May 01 '17 19:05 gsainagendraprasad