aboutsummaryrefslogtreecommitdiffstats
path: root/src/openssl.c
diff options
context:
space:
mode:
authorLibravatarLibravatar william <william@25tandclement.com> 2014-09-11 13:26:22 -0700
committerLibravatarLibravatar william <william@25tandclement.com> 2014-09-11 13:26:22 -0700
commit770faa56fec81ed3fae15e2fbd57597aaa340ade (patch)
tree5aab8f803eb8909d88d120e6fcf3a391d5a51485 /src/openssl.c
parent0588f3ad4981ea5282d4b423654e87c0170c941e (diff)
parent3b104d32c371fab0ef77f678b2cf6640255247dc (diff)
downloadluaossl-770faa56fec81ed3fae15e2fbd57597aaa340ade.tar.gz
luaossl-770faa56fec81ed3fae15e2fbd57597aaa340ade.tar.bz2
luaossl-770faa56fec81ed3fae15e2fbd57597aaa340ade.zip
Merge branch 'kunkku-crl-parse'
Diffstat (limited to 'src/openssl.c')
-rw-r--r--src/openssl.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 757bbf0..d18cf67 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -3070,14 +3070,40 @@ int luaopen__openssl_x509_csr(lua_State *L) {
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static int xx_new(lua_State *L) {
+ const char *data;
+ size_t len;
X509_CRL **ud;
+ lua_settop(L, 2);
+
ud = prepsimple(L, X509_CRL_CLASS);
- if (!(*ud = X509_CRL_new()))
- return throwssl(L, "x509.crl.new");
+ if ((data = luaL_optlstring(L, 1, NULL, &len))) {
+ int type = optencoding(L, 2, "*", X509_ANY|X509_PEM|X509_DER);
+ BIO *tmp;
+ int ok = 0;
+
+ if (!(tmp = BIO_new_mem_buf((char *)data, len)))
+ return throwssl(L, "x509.crl.new");
+
+ if (type == X509_PEM || type == X509_ANY) {
+ ok = !!(*ud = PEM_read_bio_X509_CRL(tmp, NULL, 0, "")); /* no password */
+ }
+
+ if (!ok && (type == X509_DER || type == X509_ANY)) {
+ ok = !!(*ud = d2i_X509_CRL_bio(tmp, NULL));
+ }
- X509_gmtime_adj(X509_CRL_get_lastUpdate(*ud), 0);
+ BIO_free(tmp);
+
+ if (!ok)
+ return throwssl(L, "x509.crl.new");
+ } else {
+ if (!(*ud = X509_CRL_new()))
+ return throwssl(L, "x509.crl.new");
+
+ X509_gmtime_adj(X509_CRL_get_lastUpdate(*ud), 0);
+ }
return 1;
} /* xx_new() */