diff options
author | william <william@25tandclement.com> | 2014-09-16 18:11:13 -0700 |
---|---|---|
committer | william <william@25tandclement.com> | 2014-09-16 18:11:13 -0700 |
commit | 3c27b8f14a31e14dc4037803f0892445b8581a70 (patch) | |
tree | a93f06d96a810d99d9fcaad587dfcbbc46955210 /src | |
parent | 624c021edcb1250df4efced69e688ef0607feb69 (diff) | |
download | luaossl-3c27b8f14a31e14dc4037803f0892445b8581a70.tar.gz luaossl-3c27b8f14a31e14dc4037803f0892445b8581a70.tar.bz2 luaossl-3c27b8f14a31e14dc4037803f0892445b8581a70.zip |
add :getHostName and :setHostName methods to SSL object
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 28 |
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 | ||
4420 | static 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 | |||
4433 | static 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 | |||
4420 | static int ssl__gc(lua_State *L) { | 4446 | static 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 | ||