1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

[fix] jruby hang with TLS due not executing task

basically the use of Java SSL API was incorrect ...

and reproduced when verification is enabled - the engine needs
to execute a task but the handling code was not reached
This commit is contained in:
kares 2022-05-31 11:11:09 +02:00
parent acfc0859c4
commit d1731a5607
No known key found for this signature in database
GPG key ID: 21701020A1BC3F8C

View file

@ -355,14 +355,6 @@ public class MiniSSL extends RubyObject { // MiniSSL::Engine
} }
} }
// after each op, run any delegated tasks if needed
if(res.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
Runnable runnable;
while ((runnable = engine.getDelegatedTask()) != null) {
runnable.run();
}
}
return res; return res;
} }
@ -380,11 +372,12 @@ public class MiniSSL extends RubyObject { // MiniSSL::Engine
HandshakeStatus handshakeStatus = engine.getHandshakeStatus(); HandshakeStatus handshakeStatus = engine.getHandshakeStatus();
boolean done = false; boolean done = false;
SSLEngineResult res = null;
while (!done) { while (!done) {
SSLEngineResult res;
switch (handshakeStatus) { switch (handshakeStatus) {
case NEED_WRAP: case NEED_WRAP:
res = doOp(SSLOperation.WRAP, inboundAppData, outboundNetData); res = doOp(SSLOperation.WRAP, inboundAppData, outboundNetData);
handshakeStatus = res.getHandshakeStatus();
break; break;
case NEED_UNWRAP: case NEED_UNWRAP:
res = doOp(SSLOperation.UNWRAP, inboundNetData, inboundAppData); res = doOp(SSLOperation.UNWRAP, inboundNetData, inboundAppData);
@ -392,13 +385,18 @@ public class MiniSSL extends RubyObject { // MiniSSL::Engine
// need more data before we can shake more hands // need more data before we can shake more hands
done = true; done = true;
} }
handshakeStatus = res.getHandshakeStatus();
break;
case NEED_TASK:
Runnable runnable;
while ((runnable = engine.getDelegatedTask()) != null) {
runnable.run();
}
handshakeStatus = engine.getHandshakeStatus();
break; break;
default: default:
done = true; done = true;
} }
if (!done) {
handshakeStatus = res.getHandshakeStatus();
}
} }
if (inboundNetData.hasRemaining()) { if (inboundNetData.hasRemaining()) {