summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--src/sbearssl/sbearssl_run.c30
-rw-r--r--src/stls/stls_client_init_and_handshake.c2
-rw-r--r--src/stls/stls_run.c6
-rw-r--r--src/stls/stls_server_init_and_handshake.c2
-rw-r--r--src/tls/s6-tlsc-io.c4
-rw-r--r--src/tls/s6-tlsc.c2
-rw-r--r--src/tls/s6-tlsd-io.c4
8 files changed, 27 insertions, 25 deletions
diff --git a/AUTHORS b/AUTHORS
index 8341bff..1254022 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -3,7 +3,7 @@ Main author:
Contributors:
John Regan <john@jrjrtech.com>
- Michael Forney <???@mforney.org>
+ Michael Forney <mforney@mforney.org>
Thanks to:
Jean Marot <jean.marot@skarnet.org>
diff --git a/src/sbearssl/sbearssl_run.c b/src/sbearssl/sbearssl_run.c
index c8ff2fe..44dbe88 100644
--- a/src/sbearssl/sbearssl_run.c
+++ b/src/sbearssl/sbearssl_run.c
@@ -19,7 +19,13 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint
iopause_fd x[4] ;
unsigned int xindex[4] ;
int markedforflush = 0 ;
- int handshake_done = 0 ;
+ int handshake_notdone = 1 ;
+
+ if (ndelay_on(fds[0]) < 0
+ || ndelay_on(fds[1]) < 0
+ || ndelay_on(fds[2]) < 0
+ || ndelay_on(fds[3]) < 0)
+ strerr_diefu1sys(111, "set fds non-blocking") ;
for (;;)
{
@@ -35,24 +41,17 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint
break ;
}
- if (!handshake_done)
- {
- size_t dummy ;
- if (br_ssl_engine_recvapp_buf(ctx, &dummy))
- {
- if (!(*cb)(ctx, cbarg))
- strerr_diefu1sys(111, "post-handshake callback failed") ;
- handshake_done = 1 ;
- }
- }
-
- tain_add_g(&deadline, fds[0] >= 0 && fds[2] >= 0 && state & (BR_SSL_SENDAPP | BR_SSL_RECVREC) ? tto : &tain_infinite_relative) ;
-
if (fds[0] >= 0 && state & BR_SSL_SENDAPP)
{
x[j].fd = fds[0] ;
x[j].events = IOPAUSE_READ ;
xindex[0] = j++ ;
+ if (handshake_notdone)
+ {
+ if (!(*cb)(ctx, cbarg))
+ strerr_diefu1sys(111, "post-handshake callback failed") ;
+ handshake_notdone = 0 ;
+ }
}
else xindex[0] = 4 ;
if (fds[1] >= 0 && state & BR_SSL_RECVAPP)
@@ -77,7 +76,8 @@ void sbearssl_run (br_ssl_engine_context *ctx, int *fds, tain_t const *tto, uint
}
else xindex[3] = 4 ;
- if (xindex[0] == 4 && xindex[1] == 4 && xindex[3] == 4) break ;
+ if (!j) break ;
+ tain_add_g(&deadline, fds[0] >= 0 && fds[2] >= 0 && state & (BR_SSL_SENDAPP | BR_SSL_RECVREC) ? tto : &tain_infinite_relative) ;
r = iopause_g(x, j, &deadline) ;
if (r < 0) strerr_diefu1sys(111, "iopause") ;
else if (!r) break ;
diff --git a/src/stls/stls_client_init_and_handshake.c b/src/stls/stls_client_init_and_handshake.c
index 50898ea..173942f 100644
--- a/src/stls/stls_client_init_and_handshake.c
+++ b/src/stls/stls_client_init_and_handshake.c
@@ -75,6 +75,8 @@ struct tls *stls_client_init_and_handshake (int const *fds, uint32_t preoptions,
if (tls_connect_fds(ctx, fds[0], fds[1], servername) < 0)
diectx(97, ctx, "tls_connect_fds") ;
tls_config_free(cfg) ;
+ strerr_warn1x("before handshake") ;
if (tls_handshake(ctx) < 0) diectx(97, ctx, "perform SSL handshake") ;
+ strerr_warn1x("after handshake") ;
return ctx ;
}
diff --git a/src/stls/stls_run.c b/src/stls/stls_run.c
index e6ab609..e8305bf 100644
--- a/src/stls/stls_run.c
+++ b/src/stls/stls_run.c
@@ -118,6 +118,12 @@ void stls_run (struct tls *ctx, int *fds, tain_t const *tto, uint32_t options, u
iopause_fd x[4] ;
unsigned int xindex[4] ;
+ if (ndelay_on(fds[0]) < 0
+ || ndelay_on(fds[1]) < 0
+ || ndelay_on(fds[2]) < 0
+ || ndelay_on(fds[3]) < 0)
+ strerr_diefu1sys(111, "set fds non-blocking") ;
+
buffer_init(&b[0].b, &buffer_read, fds[0], b[0].buf, STLS_BUFSIZE) ;
buffer_init(&b[1].b, &buffer_write, fds[1], b[1].buf, STLS_BUFSIZE) ;
diff --git a/src/stls/stls_server_init_and_handshake.c b/src/stls/stls_server_init_and_handshake.c
index 5d9c25c..5dd5284 100644
--- a/src/stls/stls_server_init_and_handshake.c
+++ b/src/stls/stls_server_init_and_handshake.c
@@ -77,7 +77,9 @@ struct tls *stls_server_init_and_handshake (int const *fds, uint32_t preoptions)
if (tls_accept_fds(ctx, &cctx, fds[0], fds[1]) < 0)
diectx(97, ctx, "tls_accept_fds") ;
tls_free(ctx) ;
+ strerr_warni1x("before handshake") ;
if (tls_handshake(cctx) < 0)
diectx(97, cctx, "perform SSL handshake") ;
+ strerr_warni1x("after handshake") ;
return cctx ;
}
diff --git a/src/tls/s6-tlsc-io.c b/src/tls/s6-tlsc-io.c
index 48965cc..f6a0210 100644
--- a/src/tls/s6-tlsc-io.c
+++ b/src/tls/s6-tlsc-io.c
@@ -55,8 +55,6 @@ static int handshake_cb (br_ssl_engine_context *ctx, sbearssl_handshake_cb_conte
static inline void doit (int *fds, tain_t const *tto, uint32_t preoptions, uint32_t options, unsigned int verbosity, char const *servername, unsigned int notif)
{
- if (ndelay_on(fds[0]) < 0 || ndelay_on(fds[1]) < 0)
- strerr_diefu1sys(111, "set local fds non-blocking") ;
if (!random_init()) strerr_diefu1sys(111, "initialize random device") ;
sbearssl_client_init_and_run(fds, tto, preoptions, options, verbosity, servername, &handshake_cb, notif) ;
}
@@ -111,8 +109,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
fds[1] = u ;
}
- if (ndelay_on(0) < 0 || ndelay_on(1) < 0)
- strerr_diefu1sys(111, "set stdin/stdout non-blocking") ;
if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ;
tain_now_set_stopwatch_g() ;
doit(fds, &tto, preoptions, options, verbosity, servername, notif) ;
diff --git a/src/tls/s6-tlsc.c b/src/tls/s6-tlsc.c
index 5b2e7dc..08a2ab2 100644
--- a/src/tls/s6-tlsc.c
+++ b/src/tls/s6-tlsc.c
@@ -33,7 +33,7 @@ int main (int argc, char const *const *argv)
{
unsigned int verbosity = 1 ;
unsigned int kimeout = 0 ;
- int p[4][2] ;
+ int p[4][2] = { [3] = { 6, 7 } } ;
uint32_t coptions = 0 ;
uint32_t poptions = 1 ;
pid_t pid ;
diff --git a/src/tls/s6-tlsd-io.c b/src/tls/s6-tlsd-io.c
index 14003a2..75bd1e4 100644
--- a/src/tls/s6-tlsd-io.c
+++ b/src/tls/s6-tlsd-io.c
@@ -53,8 +53,6 @@ static int handshake_cb (br_ssl_engine_context *ctx, sbearssl_handshake_cb_conte
static inline void doit (int *fds, tain_t const *tto, uint32_t preoptions, uint32_t options, unsigned int verbosity, unsigned int notif)
{
- if (ndelay_on(fds[0]) < 0 || ndelay_on(fds[1]) < 0)
- strerr_diefu1sys(111, "set local fds non-blocking") ;
if (!random_init()) strerr_diefu1sys(111, "initialize random device") ;
sbearssl_server_init_and_run(fds, tto, preoptions, options, verbosity, &handshake_cb, notif) ;
}
@@ -107,8 +105,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
fds[1] = u ;
}
- if (ndelay_on(0) < 0 || ndelay_on(1) < 0)
- strerr_diefu1sys(111, "set stdin/stdout non-blocking") ;
if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ;
tain_now_set_stopwatch_g() ;
doit(fds, &tto, preoptions, options, verbosity, notif) ;