summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/openssl.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/openssl.c b/src/openssl.c
index a8829ab..8af1d3d 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -6834,17 +6834,24 @@ static int xs_interpose(lua_State *L) {
6834static int xs_add(lua_State *L) { 6834static int xs_add(lua_State *L) {
6835 X509_STORE *store = checksimple(L, 1, X509_STORE_CLASS); 6835 X509_STORE *store = checksimple(L, 1, X509_STORE_CLASS);
6836 int i, top = lua_gettop(L); 6836 int i, top = lua_gettop(L);
6837 X509 *crt, *crt_dup;
6838 X509_CRL *crl, *crl_dup;
6837 6839
6838 for (i = 2; i <= top; i++) { 6840 for (i = 2; i <= top; i++) {
6839 if (lua_isuserdata(L, i)) { 6841 if ((crt = testsimple(L, i, X509_CERT_CLASS))) {
6840 X509 *crt = checksimple(L, i, X509_CERT_CLASS); 6842 if (!(crt_dup = X509_dup(crt)))
6841 X509 *dup; 6843 return auxL_error(L, auxL_EOPENSSL, "x509.store:add");
6842 6844
6843 if (!(dup = X509_dup(crt))) 6845 if (!X509_STORE_add_cert(store, crt_dup)) {
6846 X509_free(crt_dup);
6847 return auxL_error(L, auxL_EOPENSSL, "x509.store:add");
6848 }
6849 } else if ((crl = testsimple(L, i, X509_CRL_CLASS))) {
6850 if (!(crl_dup = X509_CRL_dup(crl)))
6844 return auxL_error(L, auxL_EOPENSSL, "x509.store:add"); 6851 return auxL_error(L, auxL_EOPENSSL, "x509.store:add");
6845 6852
6846 if (!X509_STORE_add_cert(store, dup)) { 6853 if (!X509_STORE_add_crl(store, crl_dup)) {
6847 X509_free(dup); 6854 X509_CRL_free(crl_dup);
6848 return auxL_error(L, auxL_EOPENSSL, "x509.store:add"); 6855 return auxL_error(L, auxL_EOPENSSL, "x509.store:add");
6849 } 6856 }
6850 } else { 6857 } else {