aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar William Ahern <william@25thandclement.com> 2016-12-08 16:42:49 -0800
committerLibravatarLibravatar William Ahern <william@25thandclement.com> 2016-12-08 16:42:49 -0800
commit3d740aca7a31747525a2e67f4d699fd75cf8c6f0 (patch)
treea42f45710c23f52e6bde58e2f39eb9e1d7a44929
parentdb1240b586261e3404975fa0a00a90a5cffe7363 (diff)
parent33ac392bf9b18789382af635c97d58742ab0bce3 (diff)
downloadluaossl-3d740aca7a31747525a2e67f4d699fd75cf8c6f0.tar.gz
luaossl-3d740aca7a31747525a2e67f4d699fd75cf8c6f0.tar.bz2
luaossl-3d740aca7a31747525a2e67f4d699fd75cf8c6f0.zip
Merge branch 'SSL_new' of https://github.com/daurnimator/luaossl into daurnimator-SSL_new
-rw-r--r--src/openssl.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 38c9888..a92df1a 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -7903,7 +7903,13 @@ static SSL *ssl_push(lua_State *L, SSL *ssl) {
} /* ssl_push() */
static int ssl_new(lua_State *L) {
- lua_pushnil(L);
+ SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS);
+ SSL **ud = prepsimple(L, SSL_CLASS);
+
+ *ud = SSL_new(ctx);
+
+ if (!*ud)
+ return auxL_error(L, auxL_EOPENSSL, "ssl.new");
return 1;
} /* ssl_new() */
@@ -8008,7 +8014,7 @@ static int ssl_getHostName(lua_State *L) {
static int ssl_setHostName(lua_State *L) {
SSL *ssl = checksimple(L, 1, SSL_CLASS);
- const char *host = luaL_checkstring(L, 2);
+ const char *host = luaL_optstring(L, 2, NULL);
if (!SSL_set_tlsext_host_name(ssl, host))
return auxL_error(L, auxL_EOPENSSL, "ssl:setHostName");