mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Fix hang on bad SSL handshake
Both the C and JRuby SSL implementations would hang on a bad handshake because they were not producing the EOF expected in that case. Update their error handling to behave correctly here (note: `test_ssl_v3_rejection` covers this).
This commit is contained in:
parent
310b8eba20
commit
6995981303
3 changed files with 14 additions and 11 deletions
|
@ -161,7 +161,7 @@ void raise_error(SSL* ssl, int result) {
|
|||
VALUE engine_read(VALUE self) {
|
||||
ms_conn* conn;
|
||||
char buf[512];
|
||||
int bytes, n;
|
||||
int bytes, n, error;
|
||||
|
||||
Data_Get_Struct(self, ms_conn, conn);
|
||||
|
||||
|
@ -173,7 +173,8 @@ VALUE engine_read(VALUE self) {
|
|||
|
||||
if(SSL_want_read(conn->ssl)) return Qnil;
|
||||
|
||||
if(SSL_get_error(conn->ssl, bytes) == SSL_ERROR_ZERO_RETURN) {
|
||||
error = SSL_get_error(conn->ssl, bytes);
|
||||
if(error == SSL_ERROR_ZERO_RETURN || error == SSL_ERROR_SSL) {
|
||||
rb_eof_error();
|
||||
}
|
||||
|
||||
|
|
|
@ -308,8 +308,10 @@ public class MiniSSL extends RubyObject {
|
|||
log("read(): end dump of request data <<<<\n");
|
||||
return str;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
if (DEBUG) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw getRuntime().newEOFError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,16 +88,16 @@ class TestPumaServerSSL < Test::Unit::TestCase
|
|||
assert_equal "https", body
|
||||
end
|
||||
|
||||
if defined?(JRUBY_VERSION)
|
||||
def test_ssl_v3_support_disabled_by_default
|
||||
@http.ssl_version='SSLv3'
|
||||
assert_raises(OpenSSL::SSL::SSLError) do
|
||||
@http.start do
|
||||
Net::HTTP::Get.new '/'
|
||||
end
|
||||
def test_ssl_v3_rejection
|
||||
@http.ssl_version='SSLv3'
|
||||
assert_raises(OpenSSL::SSL::SSLError) do
|
||||
@http.start do
|
||||
Net::HTTP::Get.new '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(JRUBY_VERSION)
|
||||
def test_enabling_ssl_v3_support
|
||||
@server.stop(true)
|
||||
@ctx.enable_SSLv3 = true
|
||||
|
|
Loading…
Reference in a new issue