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

Some devices occurs infinite loop in unwrap when start sslserver. #424

Open
TomWangTW opened this issue Jan 12, 2017 · 18 comments
Open

Some devices occurs infinite loop in unwrap when start sslserver. #424

TomWangTW opened this issue Jan 12, 2017 · 18 comments

Comments

@TomWangTW
Copy link

I found some devices occurs infinite loop in unwrap when start sslserver.
Is anybody know what is going on?
The condition is always true and log like this:
getHandshakeStatus NEED_WRAP
readEngineResult OK
getHandshakeStatus NEED_UNWRAP
readEngineResult OK
getHandshakeStatus NEED_UNWRAP
readEngineResult OK
....
////////////////////////
SSLSocketChannel2.java

private synchronized ByteBuffer unwrap() throws SSLException {
int rem;
do {
rem = inData.remaining();
readEngineResult = sslEngine.unwrap( inCrypt, inData );
} while ( readEngineResult.getStatus() == SSLEngineResult.Status.OK && ( rem != inData.remaining() ||
sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP ) );
inData.flip();
return inData;
}

@marci4
Copy link
Collaborator

marci4 commented Mar 15, 2017

hey @TomWangTW,

could you maybe provide a stacktrace for your issue?

Greetings
marci4

@TomWangTW
Copy link
Author

Hi Marci4,

Because this issue is type of infinite loop, so i think it is hard to get stacktrace.

But when you use some devices which android version between 5.0~5.1 and it always will happen.

@marci4
Copy link
Collaborator

marci4 commented Mar 16, 2017

Hey @TomWangTW,

I am going to reduce the use of recursive calls, hopefully this helps your problem.
I will update you with my changes!

Greetings

@marci4 marci4 self-assigned this Mar 29, 2017
@marci4
Copy link
Collaborator

marci4 commented Mar 30, 2017

Hello @TomWangTW,

I merged some changes from my development repository to the main repository.

Could you please build the jar directly from these sources and check if this fixes your issue?

Greetings
marci4

@TomWangTW
Copy link
Author

Hi marci4.
Sorry for late reply, i will test it asap and reply result to you.

@TomWangTW
Copy link
Author

Hi Marci4,

Thanks for your help but it still occurs the infinite loop in same place.

It is 100% happen in Android 5.0.x devices but work normally with other Android version...
So strange.

@marci4
Copy link
Collaborator

marci4 commented Apr 6, 2017

Hello @TomWangTW,

can I reproduce this issue in the emulator as well?

Greetings
marci4

EDIT: Tried it in the emulator, cannot reproduce it this way....
Cant change the compile-version without f***ing up my project...

@marci4 marci4 added the wss label Apr 6, 2017
@TomWangTW
Copy link
Author

Hi Marci4,

I will trace this issue when i have time, but the other project(AndroidAsync) looks work normally with Android 5.0.x.
By the way, this issue looks like same as issue 293

@marci4
Copy link
Collaborator

marci4 commented May 14, 2017

Right now I am moving away from the currently used SSLSocketChannel and write our own one!

@marci4
Copy link
Collaborator

marci4 commented May 23, 2017

Little update here:

Got a SSLSocketChannel that works with every Android version from API Level 17 -25 :)

Working on some finishing touches (including talking to the author).

Greetings
marci4

@marci4
Copy link
Collaborator

marci4 commented May 28, 2017

Hello @TomWangTW,

I merged some changes to the main branch.
For me this resolves all the issues with android!

Greetings
marci4

@miopa
Copy link

miopa commented May 30, 2017

@marci4 Is this fix in the master now? I saw some reverts in the commit log.

@marci4
Copy link
Collaborator

marci4 commented May 31, 2017

Hello @miopa,

I had to remove it. Gonna push it to the main branch anyway later again to allow more testing!

Greetings
marci4

@TomWangTW
Copy link
Author

Hello @marci4

I will upload result when i test it. By the way, do you know the root cause?

@marci4
Copy link
Collaborator

marci4 commented Jun 1, 2017

Hello @TomWangTW

the cause for this problem is this issue https://issuetracker.google.com/issues/37044892

This combined with the not so perfect usage of the SSLEngine causes the problem!

Greetings
marci4

@marci4
Copy link
Collaborator

marci4 commented Jun 2, 2017

Have to move this issue to 1.3.5...

@marci4 marci4 added this to the Release 1.3.5 milestone Jun 2, 2017
@sepehr1014
Copy link

Hundreds of our users are currently having this issue. Could you give any clues on how to solve this problem or where exactly it stems from?

@marci4
Copy link
Collaborator

marci4 commented Oct 22, 2017

Hello @sepehr1014,
this issue is caused by a bug in the android framework which was introduced in the Android L preview and made it into the release...

The only way to fix this issue is just to replace the current SSLChannel implementation with a total new one...
Any contribution is very welcome since my time for this project is limited to work!

Greetings
marci4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants