Java web app encountering SSL error when using Mailgun's email API

Hey everyone, I’m hitting a wall with my Java web application. I’ve been using Mailgun to handle email sending, but since yesterday, I’m getting this frustrating SSL error when trying to make a POST request to their API. Here’s what I’m dealing with:

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

I’m running a Spring app on AWS, and I’ve already tried restarting it, but no luck. I’m not sure if it’s a trust store issue because we’ve never set up any trust store keys before. Has anyone run into something similar or have any ideas on how to fix this? I’m completely stuck!

I’ve been there, mate. Ran into this exact issue a while back when working on a client project. What finally did the trick for me was updating the JDK to the latest version. Apparently, the newer versions come with an updated certificate store that recognizes Mailgun’s new SSL certs.

If that doesn’t sort it, you might need to dig into your JVM’s truststore. There’s a file called ‘cacerts’ in your Java installation directory. You can use the ‘keytool’ command to import Mailgun’s root certificate into it. It’s a bit of a faff, but it works.

Also, double-check your AWS config. Sometimes these cloud platforms can be finicky with outbound connections. Make sure your security groups aren’t blocking HTTPS traffic to Mailgun’s API endpoints.

Stick with it, you’ll crack it soon enough!

I encountered a similar SSL issue with Mailgun’s API recently. After some investigation, I discovered that Mailgun had updated their SSL certificates, and older Java versions might not recognize the new certificate authority.

My first step was to update the Java installation, which often resolves the problem by including the latest certificates. If that doesn’t help, updating the cacerts file manually by importing the current root certificates can solve the error.

On AWS, it’s also wise to ensure that security group settings aren’t inadvertently blocking outbound HTTPS traffic.

hey mate, had same problem last week. turns out mailgun changed their SSL cert. try updating ur java version, that might fix it. if not, u could manually update the cacerts file. also, check ur AWS security settings to make sure HTTPS traffic aint blocked. good luck!