summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Ahern <william@server.local>2012-10-15 17:37:48 -0700
committerWilliam Ahern <william@server.local>2012-10-15 17:37:48 -0700
commitfde3361cd955f6a66c8e4289e79114a4e9f38c14 (patch)
treec7e7969625c083c6cf89634a54572021a0351354
parentfaf3b50ac6159293b30293a1ccf4d596d59d2875 (diff)
downloadluaossl-fde3361cd955f6a66c8e4289e79114a4e9f38c14.tar.gz
luaossl-fde3361cd955f6a66c8e4289e79114a4e9f38c14.tar.bz2
luaossl-fde3361cd955f6a66c8e4289e79114a4e9f38c14.zip
-n
add ssl.context:setCipherList and ssl:getCipherInfo
-rw-r--r--openssl.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/openssl.c b/openssl.c
index 5062b7d..97757ab 100644
--- a/openssl.c
+++ b/openssl.c
@@ -3103,6 +3103,19 @@ static int sx_setPrivateKey(lua_State *L) {
3103} /* sx_setPrivateKey() */ 3103} /* sx_setPrivateKey() */
3104 3104
3105 3105
3106static int sx_setCipherList(lua_State *L) {
3107 SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS);
3108 const char *ciphers = luaL_checkstring(L, 2);
3109
3110 if (!SSL_CTX_set_cipher_list(ctx, ciphers))
3111 return throwssl(L, "ssl.context:setCipherList");
3112
3113 lua_pushboolean(L, 1);
3114
3115 return 1;
3116} /* sx_setCipherList() */
3117
3118
3106static int sx__gc(lua_State *L) { 3119static int sx__gc(lua_State *L) {
3107 SSL_CTX **ud = luaL_checkudata(L, 1, SSL_CTX_CLASS); 3120 SSL_CTX **ud = luaL_checkudata(L, 1, SSL_CTX_CLASS);
3108 3121
@@ -3119,6 +3132,7 @@ static const luaL_Reg sx_methods[] = {
3119 { "getVerify", &sx_getVerify }, 3132 { "getVerify", &sx_getVerify },
3120 { "setCertificate", &sx_setCertificate }, 3133 { "setCertificate", &sx_setCertificate },
3121 { "setPrivateKey", &sx_setPrivateKey }, 3134 { "setPrivateKey", &sx_setPrivateKey },
3135 { "setCipherList", &sx_setCipherList },
3122 { NULL, NULL }, 3136 { NULL, NULL },
3123}; 3137};
3124 3138
@@ -3195,6 +3209,32 @@ static int ssl_getPeerChain(lua_State *L) {
3195} /* ssl_getPeerChain() */ 3209} /* ssl_getPeerChain() */
3196 3210
3197 3211
3212static int ssl_getCipherInfo(lua_State *L) {
3213 SSL *ssl = checksimple(L, 1, SSL_CLASS);
3214 SSL_CIPHER *cipher;
3215 char descr[256];
3216
3217 if (!(cipher = SSL_get_current_cipher(ssl)))
3218 return 0;
3219
3220 lua_newtable(L);
3221
3222 lua_pushstring(L, SSL_CIPHER_get_name(cipher));
3223 lua_setfield(L, -2, "name");
3224
3225 lua_pushinteger(L, SSL_CIPHER_get_bits(cipher, 0));
3226 lua_setfield(L, -2, "bits");
3227
3228 lua_pushstring(L, SSL_CIPHER_get_version(cipher));
3229 lua_setfield(L, -2, "version");
3230
3231 lua_pushstring(L, SSL_CIPHER_description(cipher, descr, sizeof descr));
3232 lua_setfield(L, -2, "description");
3233
3234 return 1;
3235} /* ssl_getCipherInfo() */
3236
3237
3198static int ssl__gc(lua_State *L) { 3238static int ssl__gc(lua_State *L) {
3199 SSL **ud = luaL_checkudata(L, 1, SSL_CLASS); 3239 SSL **ud = luaL_checkudata(L, 1, SSL_CLASS);
3200 3240
@@ -3208,6 +3248,7 @@ static int ssl__gc(lua_State *L) {
3208static const luaL_Reg ssl_methods[] = { 3248static const luaL_Reg ssl_methods[] = {
3209 { "getPeerCertificate", &ssl_getPeerCertificate }, 3249 { "getPeerCertificate", &ssl_getPeerCertificate },
3210 { "getPeerChain", &ssl_getPeerChain }, 3250 { "getPeerChain", &ssl_getPeerChain },
3251 { "getCipherInfo", &ssl_getCipherInfo },
3211 { NULL, NULL }, 3252 { NULL, NULL },
3212}; 3253};
3213 3254