aboutsummaryrefslogtreecommitdiffstats
path: root/package/uhttpd/src/uhttpd-tls.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-07-18 14:18:31 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-07-18 14:18:31 +0000
commit6576d110d2ce6e01dce282cc64b2aea6521814a9 (patch)
tree628f71deac8a5f6afa3413da4928f1f231fbabe6 /package/uhttpd/src/uhttpd-tls.c
parent75d2ba7a5cc6c4aa8b4b67d56f9cd650d0387be2 (diff)
downloadupstream-6576d110d2ce6e01dce282cc64b2aea6521814a9.tar.gz
upstream-6576d110d2ce6e01dce282cc64b2aea6521814a9.tar.bz2
upstream-6576d110d2ce6e01dce282cc64b2aea6521814a9.zip
uhttpd: support building against openssl instead of cyassl, minor cleanups (#7827)
SVN-Revision: 27686
Diffstat (limited to 'package/uhttpd/src/uhttpd-tls.c')
-rw-r--r--package/uhttpd/src/uhttpd-tls.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/package/uhttpd/src/uhttpd-tls.c b/package/uhttpd/src/uhttpd-tls.c
index 008f8e0df6..6beae25aa1 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;
}
}
-
-