"TLS connection could not be established: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found."

Hi guys, I’m trying to make a post request but I get a certificate error.

I’m using ionic5 with capacitor and the advanced http plugin and I was wondering if there was any way to solve this?

Could you guys help me out?

Thank you

I would strongly recommend using Angular’s HttpClient instead. Not only is it much less prone to troubles like this, code using it is much cleaner and easier to maintain.

Hi,

So, how can I make SSL Pinning with Angular’s HttpClient instead of advanced-http-plugin?

Hi. I was able to solve it with the advanced http plugin. Use the SSL pinning and put the certificate in this path in IOS ios/App/www/certificates/yourcertificate.cer and in android android/app/src/main/assets/www/certificates/yourcertificate.cer
If you don’t have the www folders created, create them yourself in these paths. Tell me then if it worked for you :slight_smile:

2 Likes

When I’m pointing to a specific server I got this title’s error too…

Did you figure out what is happening to show you the error? :thinking:

can you please how did you created/generated certificate ???
I’m also stuck in this issue…

This is not fixed issue. I am still getting below error

I/X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
E/chromium: [ERROR:ssl_client_socket_impl.cc(959)] handshake failed; returned -1, SSL error code 1, net_error -202

— my app is ionic + capacitor with android platform. When i run app within chrome, it works fine and i can get data with aws api gateway which is hosted with https endpoint. But when i try to run with android emulator OR from my android phone. it doesn’t work at all.

I am stuck here.

I added certificate this path bu I still getting same error.
image