IanWambai / Chowder

Chowder for Android M-Pesa payments.
MIT License
30 stars 25 forks source link

javax.net.ssl.SSLPeerUnverifiedException #14

Closed IanWambai closed 7 years ago

IanWambai commented 7 years ago

Chowder, cause I was dumb, contains a piece of code that effectively removes the protection of HTTPS from your connections. Fixing this and updating the dependency on Bintray asap.

IanWambai commented 7 years ago

Removing the trustEveryone() method leads to this: com.alexgilleran.icesoap.exception.SOAPException: javax.net.ssl.SSLPeerUnverifiedException: Hostname safaricom.co.ke not verified. So I need to find a way around this.

IanWambai commented 7 years ago

To solve this issue I had to manually verify Safaricom SSL certificates, which is exactly as painful as it sounds. Here are the steps I took:

  1. Download the entire SSL chain from safaricom.co.ke.
  2. Use KeystoreExplorer to convert the certificates into a Bouncy Castle KeyStore format, BKS, and add the keystore into the project.
  3. Get the raw resource, which contains the keystore with all the trusted certificates (root and any intermediate certs) the use Apache HttpComponents to create an SSLSocketFactory, that verifies the server certificate withSTRICT_HOSTNAME_VERIFIER.
  4. Get an error I couldn't figure out for a few hours that was because the end-point I was using didn't have www.

Publishing to the PlayStore will hopefully work now. Updating the version on Bintray.

kinyuruwarui commented 5 years ago

Trust anchor for certification path not found And did you use pure android

kinyuruwarui commented 5 years ago

Trust anchor for certification .... Error