diff options
-rw-r--r-- | src/openssl.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/openssl.c b/src/openssl.c index 3ac0c6d..ef0c6a6 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -8020,7 +8020,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() */ @@ -8157,7 +8163,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"); |