Android SNI Issue on Devices below Android 7 - android

I am trying to send a HTTP POST request (with images, but that should not matter) to a https-secured server using an AsyncHttpClient.
On Android 7+ everything seems to be working fine, the request finishes without errors.
However, on Android 5 and 6, I am getting the following error message:
javax.net.ssl.SSLException: hostname in certificate didn't match [...]
The server is using SNI, so I'm guessing that's the problem, but why would the connection work on Android 7+ with the same code?
What is the best way to fix this? I am not allowed to make any changes on the server, so I have to find a workaround for my app.

Related

Android websocket client SSL error when connecting to server running multiple SSL enabled web applications

I am working on the Android client implementation that connects via websocket to a server. I've just enabled HTTPS on the server instance and now I am receiving this issue:
W/System.err: com.neovisionaries.ws.client.HostnameUnverifiedException: The certificate of the peer (CN=otherdomain.com) does not match the expected hostname (domain.com)
at com.neovisionaries.ws.client.SocketConnector.verifyHostname(SocketConnector.java:171)
at com.neovisionaries.ws.client.SocketConnector.doConnect(SocketConnector.java:126)
at com.neovisionaries.ws.client.SocketConnector.connect(SocketConnector.java:83)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2152)
at com.neovisionaries.ws.client.ConnectThread.runMain(ConnectThread.java:32)
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
It seems that the websocket client is finding mismatched server host names.
Some other related info:
otherdomain.com is a different one of our URLs. It is pointed to separate instance of the same web application running on the same server as domain.com which is the app I am currently working on.
My code is logging the URL that it is connecting to and I can see that it is correctly referencing domain.com:
connecting to: wss://domain.com?session_key=TheCorrectSessionKey
As noted otherdomain.com is another instance of the same web application. That instance already previously had HTTPS enabled and everything is working properly with that instance. The same client code I am using now is able to connect successfully to this instance.
The same web application has a front end page that also connects to the websocket via wss://. This is working properly in both Chrome and Firefox browsers for domain.com, as far as I can tell the only client having issues is the Android client, and it's only the domain.com variant of the app having issues, the otherdomain.com one seems to be working fine.
I found this issue opened on the library I am using for websockets. But I'm not 100% sure if my problem is related to it, but it may be. In particular someone states:
Not being able to connect to a WebSocket-enabled server domain unless it is also configured to be the default server on the website.
I assume only one site can be default, and perhaps otherdomain.com got set to default since it was completed first. This is all a bit over my head though to be honest, I'm not sure if this is relavent or not.

Cordova - Android HTTPS requests fail on 4G

I've created Cordova Android app, and I'm facing this issue:
When on 3G/4G, whenever I try to make request towards my server I get the error:
ERR_TUNNEL_CONNECTION_FAILED.
When I am on WIFI everything works fine. This is not happening on all Android devices, I am facing this issue on Samsung Galaxy A5 (nd some other Androids).
I've discovered that if we use HTTP instead of HTTPS everything is fine.
Also according to https://www.sslshopper.com/ssl-checker.html
and
https://www.digicert.com/help/
everything seems to be fine with our SSL cert.
How can we solve this issue?
This usually happens because your provider is configuring a proxy in your device.
Try checking your current APN setting and deleting the fields proxy and port from it.
This also can be caused if you are using a port different from 443
I wonder if you have found your answer or not, but still want to post answer for others looking for the solution: Note that Cordova doesn't allow https calls to Servers with untrusted ssl certificate installed on them. You can ignore this error and continue by making a small change in a cordova file.
Open “\cordova\platforms\android\CordovaLib\src\org\apache\cordova\
CordovaWebViewClient.java”. In 'onReceivedSslError' method, comment
the else part and add handler.proceed() instead.
This issues happens with mobile data connection because the default Access Point that came with carrier generally have proxy that will not allowing SSL Tunneling. All you have to do is to set Proxy and Port to nothing.
Also ensure to use only port 443 for HTTPS.

No Connection error in Volley and Socket Time out in HttpClient by Async Task

I have spend near about 3 days in this issue of No Time error of Volley,
I am calling 10 web APIs sequentially, at 4th web API I am getting No Connection error of volley, out of 12 there are specifically 4 web APIs which are giving me same error(tries asynchronous as well).
I tried same by Async Task using Http Client getting Socket Time out error for the same web APis.
Note : All these web APIs are working in IOS as well as postman properly.
Can any one please let me know that this is the android side issue or from server side, if its of android please tell me the solution , how can I get rid of it?
I have resolved this issue after doing lots of work around.
Issue was of SSL Certification, As volley doesn't support SSL so need to allow externally.
To allow SSL Refer : here Create a HttpsTrustManager class that implements X509TrustManager:

android - rest API timeout

I am developing an android application which calls http requests.
The rest API is on the same laptop (using wamp). I test the API over post man (Chrome plugin), and I get the right response after ~21s ...The strange thing is, I have received immediate answer when the api was on an other pc and other network.
I didn't change nothing on the wamp config (and I have the same version) or on the code of the rest api.
The api was written in Laravel by someone else, and worked fine on the previous laptop/server.
How could I solve this?
I just noticed that the CMS loads very slow too. I solved the issue by changing "localhost" to "127.0.0.1" in laravel/app/config/database.php

Host is unresolved: api.twitter.com:80

I am implementing twitter for android. When i am requesting for Request Token. It throws me this error:
04-27 11:25:01.163: DEBUG/ERROR=(3467): Host is unresolved: api.twitter.com:80
Before it was working fine. Suddenly it started giving this error.
Thanks in advance, aby
That sounds like a DNS lookup error. If you have a network tool suite installed that allows nameserver lookups (GTech Net Tools is one of these, and it's free) try entering api.twitter.com to see if your emulator can resolve the IP address.
One other thing to note is that you should be using HTTPS to call the OAuth resources at Twitter. From the :80 on your request, you can tell that whatever called oauth/request_token used plain old HTTP. All network communication involved in negotiating your OAuth tokens should be secured.
I understand that we can use HTTP as well(If your system lacks a security cert). You can tell the library to use HTTP call by adding the following line before the initializing the Twitter connection object.
System.setProperty("twitter4j.http.useSSL","false");
I had the same problem and after many tries it seems that the problem was in the emulator.. when trying the program on 1.5 it worked. However, it didn't work on 2.1. I opened the native emulator browser on 2.1 and it failed to load the google page (probably the emulator got an internet connection problem)

Categories

Resources