diff options
author | William Ahern <william@25thandclement.com> | 2016-11-23 18:00:32 -0800 |
---|---|---|
committer | William Ahern <william@25thandclement.com> | 2016-11-23 18:00:32 -0800 |
commit | 484f0a2d25ad25edc4888b078911cd8d636ce9e1 (patch) | |
tree | cdad5c927108b58bebfe0d8c6f6935e90029c755 /src | |
parent | 8db6494d91ebead6a187fb1c8dd4d4027cd6b808 (diff) | |
parent | 79ce69e01bf377ae26a3d40ea37454339def94bd (diff) | |
download | luaossl-484f0a2d25ad25edc4888b078911cd8d636ce9e1.tar.gz luaossl-484f0a2d25ad25edc4888b078911cd8d636ce9e1.tar.bz2 luaossl-484f0a2d25ad25edc4888b078911cd8d636ce9e1.zip |
Merge branch '67-default-cert-locations' of https://github.com/daurnimator/luaossl into daurnimator-67-default-cert-locations
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/openssl.c b/src/openssl.c index 61185cf..a8829ab 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -6871,6 +6871,18 @@ static int xs_add(lua_State *L) { } /* xs_add() */ +static int xs_addDefaults(lua_State *L) { + X509_STORE *store = checksimple(L, 1, X509_STORE_CLASS); + + if (!X509_STORE_set_default_paths(store)) + return auxL_error(L, auxL_EOPENSSL, "x509.store:addDefaults"); + + lua_pushvalue(L, 1); + + return 1; +} /* xs_addDefaults() */ + + static int xs_verify(lua_State *L) { X509_STORE *store = checksimple(L, 1, X509_STORE_CLASS); X509 *crt = checksimple(L, 2, X509_CERT_CLASS); @@ -6953,9 +6965,10 @@ static int xs__gc(lua_State *L) { static const auxL_Reg xs_methods[] = { - { "add", &xs_add }, - { "verify", &xs_verify }, - { NULL, NULL }, + { "add", &xs_add }, + { "addDefaults", &xs_addDefaults }, + { "verify", &xs_verify }, + { NULL, NULL }, }; static const auxL_Reg xs_metatable[] = { @@ -6974,6 +6987,15 @@ int luaopen__openssl_x509_store(lua_State *L) { auxL_newlib(L, xs_globals, 0); + lua_pushstring(L, X509_get_default_cert_dir()); + lua_setfield(L, -2, "CERT_DIR"); + lua_pushstring(L, X509_get_default_cert_file()); + lua_setfield(L, -2, "CERT_FILE"); + lua_pushstring(L, X509_get_default_cert_dir_env()); + lua_setfield(L, -2, "CERT_DIR_EVP"); + lua_pushstring(L, X509_get_default_cert_file_env()); + lua_setfield(L, -2, "CERT_FILE_EVP"); + return 1; } /* luaopen__openssl_x509_store() */ |