Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[javax.net.ssl.SSLPeerUnverifiedException] ERROR: Cannot verify hostname: XXXX-XXXX.api.pushwoosh.com. Response = null #44

Closed
luizfelipetx opened this issue Sep 30, 2016 · 20 comments

Comments

@luizfelipetx
Copy link

luizfelipetx commented Sep 30, 2016

Hi, Android SDK i tried add in our project here, but i receive this error on init in SDK .
Apparently this is a problem with https and your CACertificate in your domain.

XXXx-XXXX = Is my projectId i remove this here.
Full Stack :
javax.net.ssl.SSLPeerUnverifiedException: Cannot verify hostname: XXXX-XXXX.api.pushwoosh.com at android.net.SSLCertificateSocketFactory.verifyHostname(SSLCertificateSocketFactory.java:241) at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:483) at com.android.okhttp.Connection.upgradeToTls(Connection.java:131) at com.android.okhttp.Connection.connect(Connection.java:107) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294) at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206) at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345) at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89) at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197) at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:254) at com.pushwoosh.internal.b.l.a(Unknown Source) at com.pushwoosh.internal.b.l.a(Unknown Source) at com.pushwoosh.internal.b.l$1.run(Unknown Source)

Adding this code in my main activity to ignore all SSL problems certificates and others, your SDK works.

try { HttpsURLConnection.setDefaultHostnameVerifier(new NullHostNameVerifier()); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new X509TrustManager[]{new NullX509TrustManager()}, new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); }catch (Exception e){ e.printStackTrace(); }
mention about the same problem.

http://stackoverflow.com/questions/31917988/okhttp-javax-net-ssl-sslpeerunverifiedexception-hostname-domain-com-not-verifie

@shaders
Copy link
Contributor

shaders commented Oct 3, 2016

Which Android version do you have?

@luizfelipetx
Copy link
Author

luizfelipetx commented Oct 3, 2016

@shaders thanks.

running on android 4.4, and android 5, samsung galaxy s3, s4, s6 and lg , and asus.

Searching about the problem , this is a problem with certificateCA in your main domain api.xxxxx

If you try run the sample in your git , the problem is the same.

When you add the code above, works fine, but im not receive any token registration.

defaultConfig {
        applicationId "com xxxxxxxx
        minSdkVersion 14
        targetSdkVersion
        versionCode 208
        versionName "2.0.8"
        multiDexEnabled true
        signingConfig signingConfigs.debug
        renderscriptTargetApi 20
        renderscriptSupportModeEnabled true
    }

@shaders
Copy link
Contributor

shaders commented Oct 4, 2016

I totally can't reproduce this. Can you open https://XXXX-XXXX.api.pushwoosh.com in your browser?

@luizfelipetx
Copy link
Author

@shaders nginx page showing a 403
screenshot - > http://i.imgur.com/VnGBEHU.png

@shaders
Copy link
Contributor

shaders commented Oct 4, 2016

Of course please replace XXXX-XXXX with your projectId

@luizfelipetx
Copy link
Author

@shaders
I made two actions bro. Sorry , the screenshot correctly is the same result with XXXX.XXXX.
403 the result page. [test on morning... ]

I try again [now] , and after request , my browser redirect to pushwoosh login page. After login and call again url , redirected to project page.

My android log - http://i.imgur.com/Xbloenx.png

@shaders
Copy link
Contributor

shaders commented Oct 4, 2016

Sorry! My Bad! The correct URL should be:
https://XXXX-XXXX.api.pushwoosh.com/json/1.3/

Where xxxx-xxxx is your app code. Try opening the page on the device in the browser to see if certificates will be ok there.

@luizfelipetx
Copy link
Author

Ok i try this url, the result is different.

here , 3 images, requested url http:// url -> http://imgur.com/a/INXxn

another one request url https:// url - > http://imgur.com/a/jjtMc

My problem is , inside your SDK ( android in this case ) is the problem with certificates.
I understood , url is working good. But i cant change the code inside SDK to fix my problem.

com.skina.android E/Pushwoosh: [RequestManager] ERROR: Cannot verify hostname: 9FA97-E46F5.api.pushwoosh.com. Response = null
                                                              javax.net.ssl.SSLPeerUnverifiedException: Cannot verify hostname: 9FA97-E46F5.api.pushwoosh.com

If you want i can connect with you using skype or other to you see in real time this problem.

@luizfelipetx
Copy link
Author

@luizfelipetx
Copy link
Author

@shaders hi again,

I try decompile your code from Jd-gui using your Pushwoosh.jar.

I cant look exactly line on code, but apparently the problem is in this class.

http://imgur.com/a/wSJk1

Looking the code, i can check one cp.pushwoosh request without https. and another ones.

My error on android just show com.pushwoosh.internal.b.l.a(Uknownsource) ,
Maybe this help to find the problem.

Thanks again

@shaders
Copy link
Contributor

shaders commented Oct 4, 2016

We are not using self-signed certificates, you don't need to change SDK code to be able to connect to the API endpoints. Somehow your device doesn't like SSL chain and this is super weird.

The screenshots you've made - are they from desktop?

Could you open this links on a device on a device browser (Chrome on Android) instead?
This way we can see why device doesn't like SSL chain if that's the problem.

@luizfelipetx
Copy link
Author

luizfelipetx commented Oct 4, 2016

Works fine on chrome browser. url is ok.
But in code android using your sdk still showing the problem.
I try change network, using 4g, 3g, diferente router, etcs.
I running the same code on 5 distinct devices.
clonning your sample from push woosh example, and running here, same problem. ( 3distinct devices)


E/Pushwoosh: [RequestManager] ERROR: Cannot verify hostname: 9FA97-E46F5.api.pushwoosh.com. Response = null
                                                              javax.net.ssl.SSLPeerUnverifiedException: Cannot verify hostname: 9FA97-E46F5.api.pushwoosh.com
                                                                  at android.net.SSLCertificateSocketFactory.verifyHostname(SSLCertificateSocketFactory.java:241)
                                                                  at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:483)
                                                                  at com.android.okhttp.Connection.upgradeToTls(Connection.java:131)
                                                                  at com.android.okhttp.Connection.connect(Connection.java:107)
                                                                  at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
                                                                  at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
                                                                  at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
                                                                  at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
                                                                  at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
                                                                  at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
                                                                  at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:254)
                                                                  at com.pushwoosh.internal.b.l.a(Unknown Source)
                                                                  at com.pushwoosh.internal.b.l.a(Unknown Source)
                                                                  at com.pushwoosh.internal.b.l$1.run(Unknown Source)

@shaders
Copy link
Contributor

shaders commented Oct 4, 2016

What happens if you add to your AndroidManifest.xml

<meta-data android:name="PushwooshUrl" android:value="https://cp.pushwoosh.com/json/1.3/"/>

Make sure to uninstall app from the device before trying this to prevent any caching issues.

@luizfelipetx
Copy link
Author

ok, i will try.

Im not uninstall other times. I will do that.

In addition , looking on google, stackoverflow, and others places about.. I found on ignored exception in your sdk to Cordova, java too. The same expcetion, but in this code is ignored.

https://github.com/alscheuring/phonegap-pushwoosh/blob/master/platforms/android/CordovaLib/src/com/squareup/okhttp/internal/http/HttpResponseCache.java
line 437.

@shaders
Copy link
Contributor

shaders commented Oct 4, 2016

What I'm trying to do now is try different endpoints to see what could be the problem. SDK may cache the endpoint between the launches that's why uninstall necessary.

@shaders
Copy link
Contributor

shaders commented Oct 4, 2016

Ignoring SSLPeerUnverifiedException exception is dangerous as it puts your app vulnerable to MITM attack and compromises the integrity of the app's data.

@luizfelipetx
Copy link
Author

I understood. Because this im not add the code to force to bypass this domains.
I will test again here,

@luizfelipetx
Copy link
Author

I just downgrade the version of your SDK to this jar. https://github.com/kaulsa88/PushWooshAndroidDemo (using jar this project works fine)

The error desapear... ..
the problem is inside your lastest SDK. 4.8.4 not works.

@luizfelipetx
Copy link
Author

But show a error in other point


 [DeviceRegistrar] Registration error https://cp.pushwoosh.com/json/1.3/registerDevice
                                                              java.io.FileNotFoundException: https://cp.pushwoosh.com/json/1.3/registerDevice
                                                                  at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
                                                                  at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:246)
                                                                  at com.pushwoosh.internal.request.RequestManager.makeRequest(Unknown Source)
                                                                  at com.pushwoosh.internal.request.RequestManager.sendRequestSync(Unknown Source)
                                                                  at com.pushwoosh.internal.request.RequestManager$1.run(Unknown Source)

@luizfelipetx
Copy link
Author

Working registration and association device on version pushwoosh-4.1.0.jar

More recent versions show SSL error too.

@shaders shaders closed this as completed Oct 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants