diff options
author | Steven Barth <steven@midlink.org> | 2009-06-06 13:03:31 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-06-06 13:03:31 +0000 |
commit | 0d2004141917f65c3a4c7b0bc0e8005d3a47b8c8 (patch) | |
tree | eebc68fd724a424cfce48525abb37e1011f57bc0 /libs/nixio/src/tls-context.c | |
parent | c07ab17d59f9f897ce427eaf5910135d03079ece (diff) |
nixio: Add support for DER keyfiles
Diffstat (limited to 'libs/nixio/src/tls-context.c')
-rw-r--r-- | libs/nixio/src/tls-context.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libs/nixio/src/tls-context.c b/libs/nixio/src/tls-context.c index fdbe224622..e55de05cc7 100644 --- a/libs/nixio/src/tls-context.c +++ b/libs/nixio/src/tls-context.c @@ -119,7 +119,17 @@ static int nixio_tls_ctx_set_cert(lua_State *L) { static int nixio_tls_ctx_set_key(lua_State *L) { SSL_CTX *ctx = nixio__checktlsctx(L); const char *cert = luaL_checkstring(L, 2); - const int ktype = SSL_FILETYPE_PEM; + const char *type = luaL_optstring(L, 3, "pem"); + int ktype; + + if (!strcmp(type, "pem")) { + ktype = SSL_FILETYPE_PEM; + } else if (!strcmp(type, "asn1")) { + ktype = SSL_FILETYPE_ASN1; + } else { + return luaL_argerror(L, 3, "supported values: pem, asn1"); + } + return nixio__tls_pstatus(L, SSL_CTX_use_PrivateKey_file(ctx, cert, ktype)); } |