aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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");