Skip to content

Commit fbe2e0a

Browse files
author
Filip Hajny
committed
SSL fixes as per bumptech/stud#130
1 parent b002956 commit fbe2e0a

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

stud/distinfo

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
$NetBSD: distinfo,v 1.1 2013/03/16 19:41:35 jym Exp $
22

3-
SHA1 (bumptech-stud-0.3-51-g0b88039.tar.gz) = fad22d9cf008b7db8f30d8d7ca0a6fcc177714de
4-
RMD160 (bumptech-stud-0.3-51-g0b88039.tar.gz) = 66a186e1095fd127945802ab681f5948ee1d4011
5-
Size (bumptech-stud-0.3-51-g0b88039.tar.gz) = 41000 bytes
63
SHA1 (patch-Makefile) = c0794c6ebb3bdc3d55b473acec674a9f98b03ffb
74
SHA1 (patch-configuration.c) = 886226a104f84bac6902bb8a8593d37a25653563
85
SHA1 (patch-stud.8) = a6b36ab6ac8c65cbc70172a9c230b22965cbdc3d
9-
SHA1 (patch-stud.c) = 9b11693619291925376f35f1443bbec83a1d798b
6+
SHA1 (patch-stud.c) = aae56a212de51dfec4c31a9f4318818a79a51dfd

stud/patches/patch-stud.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
$NetBSD: patch-stud.c,v 1.1 2013/03/16 19:41:36 jym Exp $
1+
$NetBSD$
22

33
SunOS fixes as per https://github.com/bumptech/stud/pull/71.
4-
--- stud.c.orig 2012-08-15 10:33:39.000000000 +0000
4+
SSL fixes as per https://github.com/bumptech/stud/pull/130.
5+
6+
--- stud.c.orig 2012-08-10 23:40:19.000000000 +0000
57
+++ stud.c
68
@@ -189,9 +189,17 @@ typedef struct proxystate {
79

@@ -35,7 +37,38 @@ SunOS fixes as per https://github.com/bumptech/stud/pull/71.
3537
if(setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &optval, optlen) < 0) {
3638
ERR("Error setting TCP_KEEPIDLE on client socket: %s", strerror(errno));
3739
}
38-
@@ -1751,24 +1759,16 @@ void daemonize () {
40+
@@ -889,6 +897,13 @@ static void shutdown_proxy(proxystate *p
41+
close(ps->fd_up);
42+
close(ps->fd_down);
43+
44+
+ // Clear the SSL error queue - it might contain details
45+
+ // of errors that we haven't consumed for whatever reason.
46+
+ // If we don't, future calls to SSL_get_error will lead to
47+
+ // weird/confusing results that can throw off the handling
48+
+ // of normal conditions like SSL_ERROR_WANT_READ.
49+
+ ERR_clear_error();
50+
+
51+
SSL_set_shutdown(ps->ssl, SSL_SENT_SHUTDOWN);
52+
SSL_free(ps->ssl);
53+
54+
@@ -1197,7 +1212,15 @@ static void client_handshake(struct ev_l
55+
shutdown_proxy(ps, SHUTDOWN_SSL);
56+
}
57+
else {
58+
- LOG("{%s} Unexpected SSL error (in handshake): %d\n", w->fd == ps->fd_up ? "client" : "backend", err);
59+
+
60+
+ // Try and get more detail on the error from the SSL
61+
+ // error queue. ERR_error_string requires a char buffer
62+
+ // of 120 bytes.
63+
+ unsigned long err_detail = ERR_get_error();
64+
+ char err_msg[120];
65+
+ ERR_error_string(err_detail, err_msg);
66+
+
67+
+ LOG("{client} Unexpected SSL error (in handshake): %d, %s\n", err, err_msg);
68+
shutdown_proxy(ps, SHUTDOWN_SSL);
69+
}
70+
}
71+
@@ -1751,24 +1774,16 @@ void daemonize () {
3972
exit(0);
4073
}
4174

0 commit comments

Comments
 (0)