aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-ossl/0003-get-named-extension-from-certificate.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/lua-ossl/0003-get-named-extension-from-certificate.patch')
-rw-r--r--main/lua-ossl/0003-get-named-extension-from-certificate.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/main/lua-ossl/0003-get-named-extension-from-certificate.patch b/main/lua-ossl/0003-get-named-extension-from-certificate.patch
new file mode 100644
index 0000000000..d1da746a2e
--- /dev/null
+++ b/main/lua-ossl/0003-get-named-extension-from-certificate.patch
@@ -0,0 +1,62 @@
+From 1da611092ca5d925020ce4e51aa9e603646ff79f Mon Sep 17 00:00:00 2001
+From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
+Date: Thu, 14 May 2015 14:28:00 +0300
+Subject: [PATCH 3/5] get named extension from certificate
+
+---
+ src/openssl.c | 32 ++++++++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+
+diff --git a/src/openssl.c b/src/openssl.c
+index 941da9b..8564ce1 100644
+--- a/src/openssl.c
++++ b/src/openssl.c
+@@ -3632,6 +3632,37 @@ static int xc_addExtension(lua_State *L) {
+ } /* xc_addExtension() */
+
+
++static int xc_getExtension(lua_State *L) {
++ X509 *crt = checksimple(L, 1, X509_CERT_CLASS);
++ const char *name = luaL_checkstring(L, 2);
++
++ X509_EXTENSION *ext, **ud;
++ ASN1_OBJECT *obj = NULL;
++
++ if (!(obj = OBJ_txt2obj(name, 0)))
++ goto error;
++
++ int i = X509_get_ext_by_OBJ(crt, obj, -1);
++ if (i > -1) {
++ ud = prepsimple(L, X509_EXT_CLASS);
++ if (!(ext = X509_get_ext(crt, i)))
++ goto error;
++ if (!(*ud = X509_EXTENSION_dup(ext)))
++ goto error;
++ }
++ else lua_pushnil(L);
++
++ ASN1_OBJECT_free(obj);
++ return 1;
++
++error:
++ if (obj)
++ ASN1_OBJECT_free(obj);
++
++ return auxL_error(L, auxL_EOPENSSL, "x509.cert:getExtension");
++} /* xc_getExtension() */
++
++
+ static int xc_isIssuedBy(lua_State *L) {
+ X509 *crt = checksimple(L, 1, X509_CERT_CLASS);
+ X509 *issuer = checksimple(L, 2, X509_CERT_CLASS);
+@@ -3865,6 +3896,7 @@ static const luaL_Reg xc_methods[] = {
+ { "getBasicConstraintsCritical", &xc_getBasicConstraintsCritical },
+ { "setBasicConstraintsCritical", &xc_setBasicConstraintsCritical },
+ { "addExtension", &xc_addExtension },
++ { "getExtension", &xc_getExtension },
+ { "isIssuedBy", &xc_isIssuedBy },
+ { "getPublicKey", &xc_getPublicKey },
+ { "setPublicKey", &xc_setPublicKey },
+--
+2.1.0
+