aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-05-28 18:20:56 +1000
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-05-28 18:20:56 +1000
commit4dab4738cd19412758c358e7444c98d3dd60fbed (patch)
tree7fb1391e4b4f5fb93a8ee4d878dd243d798388f5 /src
parent0f437c5951d3b6cdb75195bbcc8b8237fb2e4969 (diff)
downloadluaossl-4dab4738cd19412758c358e7444c98d3dd60fbed.tar.gz
luaossl-4dab4738cd19412758c358e7444c98d3dd60fbed.tar.bz2
luaossl-4dab4738cd19412758c358e7444c98d3dd60fbed.zip
src/openssl.c: Add setExtension methods to match addExtension
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 52eaf55..70fc1f9 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -6221,6 +6221,25 @@ static int xc_addExtension(lua_State *L) {
} /* xc_addExtension() */
+static int xc_setExtension(lua_State *L) {
+ X509 *crt = checksimple(L, 1, X509_CERT_CLASS);
+ X509_EXTENSION *ext = checksimple(L, 2, X509_EXT_CLASS);
+ int nid, crit;
+ void *value;
+
+ nid = OBJ_obj2nid(X509_EXTENSION_get_object(ext));
+ crit = X509_EXTENSION_get_critical(ext);
+ value = X509_EXTENSION_get_data(ext);
+
+ if (!X509_add1_ext_i2d(crt, nid, value, crit, X509V3_ADD_REPLACE))
+ return auxL_error(L, auxL_EOPENSSL, "x509.cert:setExtension");
+
+ lua_pushboolean(L, 1);
+
+ return 1;
+} /* xc_setExtension() */
+
+
static int xc_getExtension(lua_State *L) {
X509 *crt = checksimple(L, 1, X509_CERT_CLASS);
X509_EXTENSION *ext = NULL, **ud;
@@ -6535,6 +6554,7 @@ static const auxL_Reg xc_methods[] = {
{ "getBasicConstraintsCritical", &xc_getBasicConstraintsCritical },
{ "setBasicConstraintsCritical", &xc_setBasicConstraintsCritical },
{ "addExtension", &xc_addExtension },
+ { "setExtension", &xc_setExtension },
{ "getExtension", &xc_getExtension },
{ "getExtensionCount", &xc_getExtensionCount },
{ "getOCSP", &xc_getOCSP },
@@ -7233,6 +7253,25 @@ static int xx_addExtension(lua_State *L) {
} /* xx_addExtension() */
+static int xx_setExtension(lua_State *L) {
+ X509_CRL *crl = checksimple(L, 1, X509_CRL_CLASS);
+ X509_EXTENSION *ext = checksimple(L, 2, X509_EXT_CLASS);
+ int nid, crit;
+ void *value;
+
+ nid = OBJ_obj2nid(X509_EXTENSION_get_object(ext));
+ crit = X509_EXTENSION_get_critical(ext);
+ value = X509_EXTENSION_get_data(ext);
+
+ if (!X509_CRL_add1_ext_i2d(crl, nid, value, crit, X509V3_ADD_REPLACE))
+ return auxL_error(L, auxL_EOPENSSL, "x509.crl:setExtension");
+
+ lua_pushboolean(L, 1);
+
+ return 1;
+} /* xx_setExtension() */
+
+
static int xx_getExtension(lua_State *L) {
X509_CRL *crl = checksimple(L, 1, X509_CRL_CLASS);
X509_EXTENSION *ext = NULL, **ud;
@@ -7372,6 +7411,7 @@ static const auxL_Reg xx_methods[] = {
{ "setIssuer", &xx_setIssuer },
{ "add", &xx_add },
{ "addExtension", &xx_addExtension },
+ { "setExtension", &xx_setExtension },
{ "getExtension", &xx_getExtension },
{ "getExtensionCount", &xx_getExtensionCount },
{ "sign", &xx_sign },