Giter Club home page Giter Club logo

Comments (51)

UXDart avatar UXDart commented on August 28, 2024

I tried:
Ion.getDefault(context).getHttpClient().getSSLSocketMiddleware().setSSLContext(SSLContext.getInstance("SSLv3"));
but doesn't work... it start at 0% and keeps there. any hint?

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

the most strange thing is that it happens when it gets to 100%, not before. so I'm not sure if using sslv3 is really the solution. I mean it should happen at any "%"... I assume. TIA

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

I'm not sure if this is right or not, but on file AsyncSSLSocketWrapper.java line 147
sslContext = SSLContext.getInstance("Default");

it doesn't call sslContext.init(...) after that, is that right? (if an exception occurs it is called, but if is not, is not called)

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

I think the problem is that it continues to expect data after it finish.
I changed some code:

on file AsyncSSLSocketWrapper.java line 86: added some Log.d(...)

                while (true) {
                    if (b.remaining() == 0 && bb.size() > 0) {
                        b = bb.remove();
                    }
                    int remaining = b.remaining();
                    Log.i("SL", "SSSSS REM1:"+remaining+" bb:"+bb.size());

                    SSLEngineResult res = engine.unwrap(b, mReadTmp);
                    if (res.getStatus() == Status.BUFFER_OVERFLOW) {
                        Log.i("SL", "SSSSS OVERFLOW");
                        addToPending(transformed);
                        mReadTmp = ByteBufferList.obtain(mReadTmp.remaining() * 2);
                        remaining = -1;
                    }
                    else if (res.getStatus() == Status.BUFFER_UNDERFLOW) {
                        Log.i("SL", "SSSSS UNDERFLOW");
                        bb.addFirst(b);
                        if (bb.size() <= 1) {
                            break;
                        }
                        remaining = -1;
                        b = bb.getAll();
                    }
                    handleResult(res);
                    if (b.remaining() == remaining) {
                        Log.i("SL", "SSSSS ====");
                        bb.addFirst(b);
                        break;
                    }
                    Log.i("SL", "SSSSS REM2:"+remaining+" bb:"+bb.size());
                }

and get this results:
I/SL: SSSSS REM1:5432 bb:0
I/SL: SSSSS REM2:5432 bb:0
I/SL: SSSSS REM1:5353 bb:0
I/SL: SSSSS REM2:5353 bb:0
I/SL: SSSSS REM1:9 bb:0
I/SL: SSSSS REM2:9 bb:0
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS ====
I/SL: SSSSS REM1:47 bb:0
I/SL: SSSSS REM2:47 bb:0
I/SL: SSSSS REM1:41 bb:0
I/SL: SSSSS REM2:41 bb:0
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS UNDERFLOW
I/SL: SSSSS REM1:27 bb:0

the error happens always when reaching the 100%.
W/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac
W/System.err: at org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:485)
W/System.err: at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
W/System.err: at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:93)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
W/System.err: at com.koushikdutta.async.Util.emitAllData(Util.java:20)
W/System.err: at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
W/System.err: at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
W/System.err: at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
W/System.err: at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
W/System.err: at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)

any idea? thanks

from androidasync.

koush avatar koush commented on August 28, 2024

If there's any way you can expose a server and url to me, I can investigate further. I have no idea what the problem is otherwise.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

no, because it is a server inside the company. what can I test? tnx

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

should be something after the SSSS =====?

from androidasync.

koush avatar koush commented on August 28, 2024

please try the changes in the issue55 branch. May fix it.

from androidasync.

koush avatar koush commented on August 28, 2024

actually hold on.

from androidasync.

koush avatar koush commented on August 28, 2024

Ok, now try issue55 branch. Had to add one more change.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

oh.. ok will download again.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

:(
it gives me this error:
W/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac
W/System.err: at org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:485)
W/System.err: at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
W/System.err: at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:91)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
W/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
W/System.err: at com.koushikdutta.async.Util.emitAllData(Util.java:20)
W/System.err: at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
W/System.err: at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
W/System.err: at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
W/System.err: at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
W/System.err: at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

also the oncomplete returns this exception:
java.lang.Exception: connection closed before response completed.
at com.koushikdutta.async.http.AsyncHttpResponseImpl$3.onCompleted(AsyncHttpResponseImpl.java:85)
at com.koushikdutta.async.AsyncSSLSocketWrapper.report(AsyncSSLSocketWrapper.java:364)
at com.koushikdutta.async.AsyncSSLSocketWrapper.access$100(AsyncSSLSocketWrapper.java:27)
at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:120)
at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
at com.koushikdutta.async.Util.emitAllData(Util.java:20)
at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

I;m adding Log.d everywhere:

                while (true) {
                    if (b.remaining() == 0 && bb.size() > 0) {
                        b = bb.remove();
                    }
                    int remaining = b.remaining();
                    Log.i("SL", "SSSSS REM1:" + remaining + " bb:" + bb.size());

                    if (read == null)
                        read = ByteBufferList.obtain(remaining * 2);

                    SSLEngineResult res = engine.unwrap(b, read);
                    addToPending(transformed, read);
                    if (res.getStatus() == Status.BUFFER_OVERFLOW) {
                        Log.i("SL", "SSSSS OVER");
                        remaining = -1;
                        read = ByteBufferList.obtain(read.capacity() * 2);
                    }
                    else if (res.getStatus() == Status.BUFFER_UNDERFLOW) {
                        Log.i("SL", "SSSSS UNDER");
                        read = null;
                        bb.addFirst(b);
                        Log.i("SL", "SSSSS UNDER bb.size:"+bb.size());
                        if (bb.size() <= 1) {
                            break;
                        }
                        remaining = -1;
                        b = bb.getAll();
                    }
                    else {
                        Log.i("SL", "SSSSS read=null");
                        read = null;
                    }
                    handleResult(res);
                    Log.i("SL", "SSSSS REM2: b"+b.remaining()+" rem:"+remaining);
                    if (b.remaining() == remaining) {
                        Log.i("SL", "SSSSS =====");
                        bb.addFirst(b);
                        break;
                    }
                }

                Log.i("SL", "SSSSS emit");
                Util.emitAllData(AsyncSSLSocketWrapper.this, transformed);

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

I/SL: SSSSS REM1:5432 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b5353 rem:5432
I/SL: SSSSS REM1:5353 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b9 rem:5353
I/SL: SSSSS REM1:9 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:9
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:0
I/SL: SSSSS =====
I/SL: SSSSS emit
I/SL: SSSSS REM1:47 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b41 rem:47
I/SL: SSSSS REM1:41 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:41
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS UNDER
I/SL: SSSSS UNDER bb.size:0
I/SL: SSSSS emit
I/SL: SSSSS REM1:134 bb:0

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

again, at 100%
and the ==== happen at 0%

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

notice that bb.size is always 0. so when goes in buffer_under.. it is going inside the "break;".. is that right?

from androidasync.

koush avatar koush commented on August 28, 2024

Yes, breaking is correct. It needs to emit more data to continue; hence the buffer underlow. It is weird that it consumes all the data on undeflow. Hmm.

from androidasync.

koush avatar koush commented on August 28, 2024

try this:

change:

                        if (b.remaining() == 0 && bb.size() > 0) {
                            b = bb.remove();
                        }

to:

                        if (b.remaining() == 0 && bb.size() > 0) {
                            b = bb.getAll();
                        }

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

no....
/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac
/System.err: at org.apache.harmony.xnet.provider.jsse.SSLEngineImpl.unwrap(SSLEngineImpl.java:485)
/System.err: at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383)
/System.err: at com.koushikdutta.async.AsyncSSLSocketWrapper$1.onDataAvailable(AsyncSSLSocketWrapper.java:93)
/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:33)
/System.err: at com.koushikdutta.async.BufferedDataEmitter.onDataAvailable(BufferedDataEmitter.java:61)
/System.err: at com.koushikdutta.async.Util.emitAllData(Util.java:20)
/System.err: at com.koushikdutta.async.AsyncNetworkSocket.onReadable(AsyncNetworkSocket.java:170)
/System.err: at com.koushikdutta.async.AsyncServer.runLoop(AsyncServer.java:805)
/System.err: at com.koushikdutta.async.AsyncServer.run(AsyncServer.java:664)
/System.err: at com.koushikdutta.async.AsyncServer.access$700(AsyncServer.java:34)
/System.err: at com.koushikdutta.async.AsyncServer$14.run(AsyncServer.java:612)

from androidasync.

koush avatar koush commented on August 28, 2024

Try using SSLEngine.setEnabledProtocols to hardcode enabling SSLv3.

from androidasync.

koush avatar koush commented on August 28, 2024
        if (host != null) {
            engine = sslContext.createSSLEngine(host, port);
        }
        else {
            engine = sslContext.createSSLEngine();
        }

after those lines add,

engine.setEnabledProtocols(new String[] { "SSLv3" });

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

ok, will try. with the bb.getAll or bb.remove ?

from androidasync.

koush avatar koush commented on August 28, 2024

Try both, but I think forcing only SSLv3 may fix this.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

with getall and with .remove gives the same error. should I try the master branch with the sslv3 line?

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

Remember that I'm using Ion, is Ion using that SSLContext?

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

all comments I found on google said that using sslv3 should solve that

from androidasync.

koush avatar koush commented on August 28, 2024

Try the SSLv3 fix. It doesn't matter which branch. You'll need to make the change in AndroidAsync. See the code I mentioned above.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

it doesn't work: I changed:

    if (host != null) {
        engine = sslContext.createSSLEngine(host, port);
    }
    else {
        engine = sslContext.createSSLEngine();
    }
    engine.setEnabledProtocols(new String[] { "SSLv3" }); 

W/System.err: javax.net.ssl.SSLException: Fatal alert received bad_record_mac

I/SL: SSSSS REM1:5432 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b5353 rem:5432
I/SL: SSSSS REM1:5353 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b9 rem:5353
I/SL: SSSSS REM1:9 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:9
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:0
I/SL: SSSSS =====
I/SL: SSSSS REM1:71 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b65 rem:71
I/SL: SSSSS REM1:65 bb:0
I/SL: SSSSS read=null
I/SL: SSSSS REM2: b0 rem:65
I/SL: SSSSS REM1:0 bb:0
I/SL: SSSSS UNDER
I/SL: SSSSS UNDER bb.size:0
I/SL: SSSSS REM1:134 bb:0

from androidasync.

koush avatar koush commented on August 28, 2024

Try SSLv2 then.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

it hangs at 0%

from androidasync.

koush avatar koush commented on August 28, 2024

Try TLSv1.2.

Also try disabling SSLv3 on your server. It's apparently insecure anyways.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

the server only works with tlsv1 and ssl3. do I have a way to contact you directly? I can give you tomorrow if you can access, to a server so you can test it. but it needs to be during tomorrow, I don't know if you can..?

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

I will make some tests anyway. I found that in some cases it works, when using the call from another part of the app. but not always. I will let you know. thanks

from androidasync.

koush avatar koush commented on August 28, 2024

Try TLSv1 then. Trying to determine what the issue is.

koushikdutta _ at _ hotmail.com is my address

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

I just sent you an email. Thanks!

btw, it didn't work with TLSv1 :(

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

do you think you will can test it today? thanks

from androidasync.

koush avatar koush commented on August 28, 2024

Not today, probably tomorrow or monday.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

ok, I need to disable the account. I will enable it again tomorrow and send you an email, if you are ok with that... thanks!

from androidasync.

koush avatar koush commented on August 28, 2024

ok

from androidasync.

koush avatar koush commented on August 28, 2024

Resolved as probable issue with SSLv3 stack on Apache server.

from androidasync.

koush avatar koush commented on August 28, 2024

From email:

I tested this request a dozen times against my own http(s) server. It worked every time.
I tested this many times against your NON-https, normal http post path, and it worked every time.
I tested this against your https server, and it fails fairly consistently.

From my searching, Apache is known to have issues with SSL termination using SSLv3. I'm fairly confident that the issue is with the server and client interaction over https. The client (AndroidAsync) is not at fault (since it works with the three other servers I tested, including your own http, not https, server). But it is triggering the failure code path fairly consistently for whatever reason on https.

I would recommend changing the configuration of the apache server, as I can not fix this in the library... there's nothing I can fix that I can tell.

from androidasync.

koush avatar koush commented on August 28, 2024

Hi @UXDart , can you try this out:

ae9afc3

from androidasync.

koush avatar koush commented on August 28, 2024

@hiddenmin If possible, please give me a web server I can test against.

from androidasync.

amincheloh avatar amincheloh commented on August 28, 2024
https://node.whereteam.com:8080/upload.php

I tested last commit with Ion no SSLException but freeze after upload about 25kbytes.

from androidasync.

koush avatar koush commented on August 28, 2024

@hiddenmin Thanks, I just fixed the hang issue with:
04f2040

I then tested a 1MB post of a file and a couple fields against:
https://node.whereteam.com:8080/upload.php

This resulted in an "ok" response.

Let me know if this resolves your issue. If not, please provide a Phone model and Android version, and I can debug further.

from androidasync.

amincheloh avatar amincheloh commented on August 28, 2024

Thanks @koush. You saved my life.

from androidasync.

koush avatar koush commented on August 28, 2024

@UXDart Do you mind seeing if this resolved your bad_record_mac as well? I think they were the same bug.

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

thanks, I will check it and let you know

from androidasync.

UXDart avatar UXDart commented on August 28, 2024

sorry I couldn't test it before. it works!!!! :) this is great! thanks!

from androidasync.

koush avatar koush commented on August 28, 2024

Great!

from androidasync.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.