Add cert:issued(leafcert) for checking chains

This commit is contained in:
Kim Alvefur 2014-04-19 22:58:28 +02:00
parent 21aefcf67d
commit d2c87d71f7

View File

@ -393,6 +393,17 @@ static int meth_notafter(lua_State *L)
return push_asn1_time(L, X509_get_notAfter(cert)); return push_asn1_time(L, X509_get_notAfter(cert));
} }
/**
* Check if this certificate issued some other certificate
*/
static int meth_issued(lua_State *L)
{
X509* issuer = lsec_checkx509(L, 1);
X509* subject = lsec_checkx509(L, 2);
lua_pushboolean(L, X509_check_issued(issuer, subject) == X509_V_OK);
return 1;
}
/** /**
* Collect X509 objects. * Collect X509 objects.
*/ */
@ -459,6 +470,7 @@ static luaL_Reg methods[] = {
{"issuer", meth_issuer}, {"issuer", meth_issuer},
{"notbefore", meth_notbefore}, {"notbefore", meth_notbefore},
{"notafter", meth_notafter}, {"notafter", meth_notafter},
{"issued", meth_issued},
{"pem", meth_pem}, {"pem", meth_pem},
{"serial", meth_serial}, {"serial", meth_serial},
{"subject", meth_subject}, {"subject", meth_subject},