German Pared
German Pared

Reputation: 11

Using the AWS SDK - Error PKIX path building failed running inside an AWS Lambda function

I'm getting this random error: error: Unable to execute HTTP request: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target using the sdk of ssm to get parameter store values. I'm running the code inside was lambda function with Java8.

The version used is https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-ssm/1.11.788

Upvotes: 1

Views: 2422

Answers (2)

Frank
Frank

Reputation: 96

I encountered a similar issue when sending MQTT messages using AWS IoT. The error message was "PKIX path building failed."

I eventually found out that the API I was using was actually defaulting to HTTP instead of HTTPS for communication. Once I configured it to use HTTPS, the problem was resolved.

thecode as follows:

            return IotDataPlaneClient.builder()
            .region(Region.of(region))
            .credentialsProvider(StaticCredentialsProvider.create(credentials))
            // here  https!!!!!
            .endpointOverride(URI.create("https://xxxxxx"))
            .build();

Upvotes: 0

Elsis
Elsis

Reputation: 376

This error usually occurs when the server expects a certificate, but the client does not provide one, or the provided certificate does not match the certificate configured on the server side.

I found this blog post that AWS created which explains how to fix the issue:

https://aws.amazon.com/blogs/compute/implementing-mutual-tls-for-java-based-aws-lambda-functions/

Upvotes: 0

Related Questions