-
Notifications
You must be signed in to change notification settings - Fork 260
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
Error when connecting from Android to a server that does not support TLS 1.0 #173
Comments
Hi, I also have issues with connecting to websites using TLS. The following code works when I call the google website but not my own website that is using a CA signed certificate.
It may be that it works with google because it is using SSLv3 instead of TLS 1.2 Google: Supported versions: SSLv3 TLSv1.0 TLSv1.1 TLSv1.2 Server certificate(s): Minimal encryption strength: strong encryption (96-bit or more) Our website only supports TLS 1.2: Supported versions: TLSv1.2 Server certificate(s): Minimal encryption strength: strong encryption (96-bit or more) The exception we get is this: [MonoDroid] UNHANDLED EXCEPTION: |
I know that in my own project, I encountered this same issue. What I discovered was that before Android Jelly Bean, they did not support TLS 1.1 and 1.2. This caused devices running before then not to be able to connect to my server that did not accept anything less. In JB and KitKat, devices supported this, but it was not enabled by default. This leads to them not being able to connect either. Lollipop changed to have support enabled by default, therefore those devices worked for me. The fix employed by myself was to make a custom SSLSocketFactory that is used to supply the OkHttp client. It then does
For each CreateSocket method in there. And in the NativeMessageHandler constructor, I added:
This allowed me to communicate with TLS 1.1 and 1.2. I can post the code better if desired, but my git skills are not great for a pull request. |
Thanks adammeaney , I will try that and see if it works. I can probably put together a pull request for this code. |
Adammeaney...can you provide a sample of that? Banging my newbie Android developer head against the wall over here. I'm targeting API 19 |
This is a pretty lazy feeling implementation, but it works for me.
|
Thanks adammeaney I'll give it a spin |
Is it possible to do this without changing the NativeMessageHandler code? |
Not that I was able to discover. The problem was that the sockets normally created did not know they supported TLS 1.1 or 1.2 further back. There may be another way to tell the device they should be supported. I have seen code using something called ServicePointManager when I was looking for this, but none of that code seemed to resolve my issues. This was the first things I discovered. If we get lucky, @paulcbetts will patch something similar into ModernHttpClient eventually, so we can go back to just using his released package. |
I tried to use your code, but it does not work for me here is the url that does not work: Have you a change to check if it works for you? |
I wrote this code before the changes were made to use the official OkHttp client in this repo. With the official client, I do not seem to get the same results as before. I have not yet bothered to determine why, as I have it working for now and don't have the time to deal with http clients not working quite right. |
Is it someone that have a solution on this? |
An official fix would be nice, but Adam's code appears to work for me with a fork of the repo as it stands today. |
… Lollipop Error when connecting from Android to a server that does not support TLS 1.0
Can the commit to kunni80's forked repo please be reintegrated? |
I'm hoping this get merged soon. |
I am attempting to use ModernHttpClient to get around the mono limitation of not supporting HTTPS/TLS 1.1. For PCI reasons this is necessary in my app.
ModernHttpClient works great to resolve the issue on iPhone, but on android, I get the following when attempting an HTTP GET to a server that only support TLS 1.1 and above.
The text was updated successfully, but these errors were encountered: