Push Notification HTTP request: Certificate issue

Hi!
I’m testing the Push Notification of Expo from my backend down to the mobile, but I can’t manage to send the notifications. I’m getting this exception in the backend upon sending the POST to the Expo server:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Apparently, it has something to do with certificate??
Is it because I’m starting my server in localhost so my call to it (to send the notifications) is in http and it must be in https?
I’m using the HTTP way to send notification (My backend is in Java) https://docs.expo.io/versions/latest/guides/push-notifications.html#http2-api

Here’s my api call:

 private Response sendRequest(List<String> messages) {
        Client client = ClientBuilder.newClient();

        return client.target("https://exp.host/--/api/v2/push/send")
                     .request()
                     .header("accept", "application/json")
                     .header("accept-encoding", "gzip, deflate")
                     .header("content-type", "application/json")
                     .post(Entity.json(messages));
    }
1 Like

Some versions of Java don’t ship with the Root CA that Let’s Encrypt uses to sign its TLS certificates. Looking online, Java 8u101+ and 7u111+ should support it.

If that doesn’t work or you’re using a different version of Java, you can read this thread to learn how to download the Let’s Encrypt PEM or DER files and add them to your list of trusted CAs: https://community.letsencrypt.org/t/will-the-cross-root-cover-trust-by-the-default-list-in-the-jdk-jre/134/56

2 Likes

Thanks!
My Mac java version was ok, but the one setup in my IDE was too 8u73… Updating it to the newest one make the notification works woot!

1 Like

Thanks, took me an hour of digging around to find this fix