summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 03f3f8d..8efb348 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -4417,6 +4417,32 @@ static int ssl_getCipherInfo(lua_State *L) {
4417} /* ssl_getCipherInfo() */ 4417} /* ssl_getCipherInfo() */
4418 4418
4419 4419
4420static int ssl_getHostName(lua_State *L) {
4421 SSL *ssl = checksimple(L, 1, SSL_CLASS);
4422 const char *host;
4423
4424 if (!(host = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name)))
4425 return 0;
4426
4427 lua_pushstring(L, host);
4428
4429 return 1;
4430} /* ssl_getHostName() */
4431
4432
4433static int ssl_setHostName(lua_State *L) {
4434 SSL *ssl = checksimple(L, 1, SSL_CLASS);
4435 const char *host = luaL_checkstring(L, 2);
4436
4437 if (!SSL_set_tlsext_host_name(ssl, host))
4438 return throwssl(L, "ssl:setHostName");
4439
4440 lua_pushboolean(L, 1);
4441
4442 return 1;
4443} /* ssl_setHostName() */
4444
4445
4420static int ssl__gc(lua_State *L) { 4446static int ssl__gc(lua_State *L) {
4421 SSL **ud = luaL_checkudata(L, 1, SSL_CLASS); 4447 SSL **ud = luaL_checkudata(L, 1, SSL_CLASS);
4422 4448
@@ -4434,6 +4460,8 @@ static const luaL_Reg ssl_methods[] = {
4434 { "getPeerCertificate", &ssl_getPeerCertificate }, 4460 { "getPeerCertificate", &ssl_getPeerCertificate },
4435 { "getPeerChain", &ssl_getPeerChain }, 4461 { "getPeerChain", &ssl_getPeerChain },
4436 { "getCipherInfo", &ssl_getCipherInfo }, 4462 { "getCipherInfo", &ssl_getCipherInfo },
4463 { "getHostName", &ssl_getHostName },
4464 { "setHostName", &ssl_setHostName },
4437 { NULL, NULL }, 4465 { NULL, NULL },
4438}; 4466};
4439 4467