X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/8618e98eabec2b5677698daa631f195cae92c30b..040047ef04833541ea55ddf0285f940bf268d9b8:/package/uhttpd/src/uhttpd-tls.c diff --git a/package/uhttpd/src/uhttpd-tls.c b/package/uhttpd/src/uhttpd-tls.c index 008f8e0df..6beae25aa 100644 --- a/package/uhttpd/src/uhttpd-tls.c +++ b/package/uhttpd/src/uhttpd-tls.c @@ -23,7 +23,8 @@ SSL_CTX * uh_tls_ctx_init() { - SSL_CTX *c = NULL; + SSL_CTX *c; + SSL_load_error_strings(); SSL_library_init(); @@ -59,13 +60,36 @@ void uh_tls_ctx_free(struct listener *l) } -void uh_tls_client_accept(struct client *c) +int uh_tls_client_accept(struct client *c) { + int rv; + if( c->server && c->server->tls ) { c->tls = SSL_new(c->server->tls); - SSL_set_fd(c->tls, c->socket); + if( c->tls ) + { + if( (rv = SSL_set_fd(c->tls, c->socket)) < 1 ) + goto cleanup; + if( (rv = SSL_accept(c->tls)) < 1 ) + goto cleanup; + } + else + rv = 0; + } + else + { + c->tls = NULL; + rv = 1; } + +done: + return rv; + +cleanup: + SSL_free(c->tls); + c->tls = NULL; + goto done; } int uh_tls_client_recv(struct client *c, void *buf, int len) @@ -90,5 +114,3 @@ void uh_tls_client_close(struct client *c) c->tls = NULL; } } - -