Skip to content

Document how to use Conscrypt on Android #3301

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

Closed
wants to merge 2 commits into from

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Aug 2, 2017

No description provided.

@kraghu
Copy link

kraghu commented Aug 2, 2017

@ejona86 can you update the size of the Conscrypt it will add to the app in read me ?

@ericgribkoff
Copy link
Contributor

I don't think we can put a size in the readme, as new releases of the Conscrypt jar may change the size. There are tools available to figure out the APK size for a library, such as http://www.methodscount.com/?lib=org.conscrypt%3Aconscrypt-android%3A1.0.0.RC9

Copy link
Contributor

@ericgribkoff ericgribkoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although we should probably wait until google/conscrypt#276 is fixed to merge this in.

You may need to [update the security provider](https://developer.android.com/training/articles/security-gms-provider.html) to enable ALPN support, especially for Android versions < 5.0. If the provider fails to update, ALPN may not work.
Although ALPN mostly works on newer Android releases (especially since 5.0),
there are bugs that impact users that are only fixed by upgrading the security
provider. In addition, for many users it is updated more quickly after
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "it" here is a little bit confusing. Would it convey the same message to combine this and the previous sentence, into something like this:

Although ALPN mostly works on newer Android releases (especially since 5.0),
there are bugs and discovered security vulnerabilities that are only fixed by
upgrading the security provider. Thus, we recommend using the Play Service
Dynamic Security Provider for all Android versions.

@ericgribkoff
Copy link
Contributor

Quick update: as pointed out on google/conscrypt#276, our OkHttpProtocolNegotiator.AndroidNegotiator#pickTlsExtensionType code is deciding based on the detected API level not to turn on ALPN for older devices, unless the GMSCore OpenSSL provider is found. Adding Conscrypt doesn't change the result of this check, so it's only enabling NPN. I'll send out a fix for this.

Additionally, on the devices I've tested, the instructions here require removing the existing provider (Security.removeProvider("AndroidOpenSSL");) before installing Conscrypt to take its place, although I'll have to look into this a bit more as I'm not confident that this is the most robust way to handle this.

@ejona86
Copy link
Member Author

ejona86 commented Aug 18, 2017

Additionally, on the devices I've tested, the instructions here require removing the existing provider (Security.removeProvider("AndroidOpenSSL");) before installing Conscrypt to take its place, although I'll have to look into this a bit more as I'm not confident that this is the most robust way to handle this.

We should discuss this some, as I'm having to figure out how I want to detect Conscrypt with OpenJDK. But as a basic workaround you can do Security.addProvider(Conscrypt.newProvider("SomeDifferentName")).

@kraghu
Copy link

kraghu commented Aug 18, 2017

@ericgribkoff @ejona86 am still waiting on this update. Please keep me posted asap. I also noticed when i run debugger for some weird reason grpc calls work on api 19 devices.

If it helps I also notices api 19 devices available in the market are really lower api devices got upgraded at least in UI terms they behave exactly like 15 or 16 .

@ejona86
Copy link
Member Author

ejona86 commented Aug 19, 2017

@ericgribkoff, I just thought of a hack that I think will work for @kraghu until we fix the gRPC bug. Just name Conscrypt "GmsCore_OpenSSL". That will avoid the Android version detection.

Security.insertProviderAt(Conscrypt.newProvider("GmsCore_OpenSSL"), 1);

(insertProviderAt(blah, 1) makes sure it is clear it is the most-preferred provider. While the addProvider(blah) would work today, we feel we will need to make some changes in the search order that could break it in the future.)

@kraghu
Copy link

kraghu commented Aug 21, 2017

@ejona86 @ericgribkoff I tried this approach . No Luck :( It is throwing

GRPC ERROR:Status{code=UNAVAILABLE, description=null, cause=javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x636b66c0: Failure in SSL library, usually a protocol error
    error:140740B5:SSL routines:SSL23_CLIENT_HELLO:no ciphers available (external/openssl/ssl/s23_clnt.c:486 0x5d4e17d0:0x00000000)
        at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:448)
        at io.grpc.okhttp.OkHttpProtocolNegotiator.negotiate(OkHttpProtocolNegotiator.java:103)
        at io.grpc.okhttp.OkHttpProtocolNegotiator$AndroidNegotiator.negotiate(OkHttpProtocolNegotiator.java:169)
        at io.grpc.okhttp.OkHttpTlsUpgrader.upgrade(OkHttpTlsUpgrader.java:76)
        at io.grpc.okhttp.OkHttpClientTransport$1.run(OkHttpClientTransport.java:433)
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:117)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)
     Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x636b66c0: Failure in SSL library, usually a protocol error
    error:140740B5:SSL routines:SSL23_CLIENT_HELLO:no ciphers available (external/openssl/ssl/s23_clnt.c:486 0x5d4e17d0:0x00000000)
        at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
        at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
        	... 8 more
    }

@ejona86
Copy link
Member Author

ejona86 commented Jan 17, 2018

Closed in favor of #3971.

@ejona86 ejona86 closed this Jan 17, 2018
@ejona86 ejona86 deleted the security-conscrypt branch January 17, 2018 17:55
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants