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

segfault using sslsocketfactory.createSocket from test package #753

Closed
andaag opened this issue Apr 23, 2014 · 7 comments
Closed

segfault using sslsocketfactory.createSocket from test package #753

andaag opened this issue Apr 23, 2014 · 7 comments

Comments

@andaag
Copy link

andaag commented Apr 23, 2014

Hi

We have a project where our espresso tests require the use of a socket (to trigger a "this newly registered user has verified their email account, and should be allowed to login").

The way this works is that the tests run:

SSLSocketFactory sslsocketfactory = okHttpClient.getSslSocketFactory(); clientSocket = sslsocketfactory.createSocket(HOST, PORT); in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); out = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));

OkHttpClient in this case we get from our application (not application's tests). In our application we run this:

URL.setURLStreamHandlerFactory(okHttpClient); okHttpClient.setSslSocketFactory(HttpsURLConnection.getDefaultSSLSocketFactory());

I'm not entirely clear on how the ssl context works in relation between the app. A quick test shows the code works when being run in the app, but not when being run in the test. If I try to setUrlStreamHandlerFactory/setSslSocketFactory in the test context as well I'm told it's already set.

We've also tried using SSLSocketFactory.getDefault(), it also segfaults.

@swankjesse
Copy link
Collaborator

Which version of OkHttp? Which version of Android? There's a fix in 1.5.4 that disables ALPN, which is broken in Android 4.4.

@andaag
Copy link
Author

andaag commented Apr 23, 2014

Sorry about the missing info. okhttp 1.5.4 and we originally saw this on the x86 android 4.4 emulator, but I tested it on a device 4.4 and it failed immediately there aswel. I haven't tested on other versions, but I can do that tomorrow when I'm back at work.

@swankjesse
Copy link
Collaborator

Can you paste the segfault dump from logcat? Usually this is triggered by sharing an SSLContext between OkHttp and non-OkHttp.

@andaag
Copy link
Author

andaag commented Apr 23, 2014

Sorry.. worst bugreport ever, I did copy that into my clipboard, but I wrote half of the bugreport before a meeting, and finished it and clicked submit when I came back.

https://gist.github.com/andaag/d61d752efeaf5a4d7381

@swankjesse
Copy link
Collaborator

@andaag don't use the system default SSLSocketFactory with OkHttp. If you delete this line, you'll be all good:

   okHttpClient.setSslSocketFactory(HttpsURLConnection.getDefaultSSLSocketFactory());

@andaag
Copy link
Author

andaag commented May 5, 2014

@swankjesse Ok, so that's no longer required? We have that because you told me to add it ;)

#647

//edit, no you did not, you told us to add the other line. And I put the comment on the wrong line, no idea where that other one comes from. Thanks!

@swankjesse
Copy link
Collaborator

Glad to hear it's fixed.

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