summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openssl.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 5e16e56..c5c692f 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -8277,6 +8277,26 @@ static int xp_interpose(lua_State *L) {
8277} /* xp_interpose() */ 8277} /* xp_interpose() */
8278 8278
8279 8279
8280static int xp_inherit(lua_State *L) {
8281 X509_VERIFY_PARAM *dest = checksimple(L, 1, X509_VERIFY_PARAM_CLASS);
8282 X509_VERIFY_PARAM *src = checksimple(L, 2, X509_VERIFY_PARAM_CLASS);
8283 int flags = luaL_optinteger(L, 3, 0);
8284 unsigned long save_flags = dest->inh_flags;
8285 int ret;
8286
8287 dest->inh_flags |= flags;
8288 ret = X509_VERIFY_PARAM_inherit(dest, src);
8289 dest->inh_flags = save_flags;
8290
8291 if (!ret)
8292 /* Note: openssl doesn't set an error as it should for some cases */
8293 return auxL_error(L, auxL_EOPENSSL, "x509.verify_param:inherit");
8294
8295 lua_pushboolean(L, 1);
8296 return 1;
8297} /* xp_inherit() */
8298
8299
8280static const X509_PURPOSE *purpose_checktype(lua_State *L, int index) { 8300static const X509_PURPOSE *purpose_checktype(lua_State *L, int index) {
8281 const char *purpose_name; 8301 const char *purpose_name;
8282 int purpose_id; 8302 int purpose_id;
@@ -8433,6 +8453,7 @@ static int xp__gc(lua_State *L) {
8433 8453
8434 8454
8435static const auxL_Reg xp_methods[] = { 8455static const auxL_Reg xp_methods[] = {
8456 { "inherit", &xp_inherit },
8436 { "setPurpose", &xp_setPurpose }, 8457 { "setPurpose", &xp_setPurpose },
8437 { "setTime", &xp_setTime }, 8458 { "setTime", &xp_setTime },
8438 { "setDepth", &xp_setDepth }, 8459 { "setDepth", &xp_setDepth },
@@ -8459,10 +8480,20 @@ static const auxL_Reg xp_globals[] = {
8459 { NULL, NULL }, 8480 { NULL, NULL },
8460}; 8481};
8461 8482
8483static const auxL_IntegerReg xp_inherit_flags[] = {
8484 { "DEFAULT", X509_VP_FLAG_DEFAULT },
8485 { "OVERWRITE", X509_VP_FLAG_OVERWRITE },
8486 { "RESET_FLAGS", X509_VP_FLAG_RESET_FLAGS },
8487 { "LOCKED", X509_VP_FLAG_LOCKED },
8488 { "ONCE", X509_VP_FLAG_ONCE },
8489 { NULL, 0 }
8490};
8491
8462int luaopen__openssl_x509_verify_param(lua_State *L) { 8492int luaopen__openssl_x509_verify_param(lua_State *L) {
8463 initall(L); 8493 initall(L);
8464 8494
8465 auxL_newlib(L, xp_globals, 0); 8495 auxL_newlib(L, xp_globals, 0);
8496 auxL_setintegers(L, xp_inherit_flags);
8466 8497
8467 return 1; 8498 return 1;
8468} /* luaopen__openssl_x509_verify_param() */ 8499} /* luaopen__openssl_x509_verify_param() */