diff options
author | daurnimator <quae@daurnimator.com> | 2016-12-19 03:31:45 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2016-12-20 22:41:50 +1100 |
commit | 6dbb57f26a8b9120910e90c37ad4fc5f44ad13a9 (patch) | |
tree | 275bef08e6ee27187298a48653242700c49249a3 | |
parent | a92a050cb5d2c2e87ec855632bceef30791d8984 (diff) | |
download | luaossl-6dbb57f26a8b9120910e90c37ad4fc5f44ad13a9.tar.gz luaossl-6dbb57f26a8b9120910e90c37ad4fc5f44ad13a9.tar.bz2 luaossl-6dbb57f26a8b9120910e90c37ad4fc5f44ad13a9.zip |
Add cert:getOCSP() to retreive OCSP URI from a certificate
-rw-r--r-- | src/openssl.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 98043d9..59d4783 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
@@ -5950,6 +5950,40 @@ static int xc_getExtensionCount(lua_State *L) { | |||
5950 | } /* xc_getExtensionCount() */ | 5950 | } /* xc_getExtensionCount() */ |
5951 | 5951 | ||
5952 | 5952 | ||
5953 | static int sk_openssl_string__gc(lua_State *L) { | ||
5954 | STACK_OF(OPENSSL_STRING) **res = lua_touserdata(L, 1); | ||
5955 | |||
5956 | if (*res) { | ||
5957 | sk_OPENSSL_STRING_free(*res); | ||
5958 | *res = NULL; | ||
5959 | } | ||
5960 | |||
5961 | return 0; | ||
5962 | } /* sk_openssl_string__gc() */ | ||
5963 | |||
5964 | |||
5965 | static int xc_getOCSP(lua_State *L) { | ||
5966 | X509 *crt = checksimple(L, 1, X509_CERT_CLASS); | ||
5967 | STACK_OF(OPENSSL_STRING) **res = prepsimple(L, NULL, &sk_openssl_string__gc); | ||
5968 | int num, i; | ||
5969 | |||
5970 | *res = X509_get1_ocsp(crt); | ||
5971 | if (!*res) | ||
5972 | return 0; | ||
5973 | |||
5974 | num = sk_OPENSSL_STRING_num(*res); | ||
5975 | luaL_checkstack(L, num, "too many authorityInfoAccess"); | ||
5976 | for (i = 0; i < num; i++) { | ||
5977 | lua_pushstring(L, sk_OPENSSL_STRING_value(*res, i)); | ||
5978 | } | ||
5979 | |||
5980 | sk_OPENSSL_STRING_free(*res); | ||
5981 | *res = NULL; | ||
5982 | |||
5983 | return num; | ||
5984 | } /* xc_getOCSP */ | ||
5985 | |||
5986 | |||
5953 | static int xc_isIssuedBy(lua_State *L) { | 5987 | static int xc_isIssuedBy(lua_State *L) { |
5954 | X509 *crt = checksimple(L, 1, X509_CERT_CLASS); | 5988 | X509 *crt = checksimple(L, 1, X509_CERT_CLASS); |
5955 | X509 *issuer = checksimple(L, 2, X509_CERT_CLASS); | 5989 | X509 *issuer = checksimple(L, 2, X509_CERT_CLASS); |
@@ -6191,6 +6225,7 @@ static const auxL_Reg xc_methods[] = { | |||
6191 | { "addExtension", &xc_addExtension }, | 6225 | { "addExtension", &xc_addExtension }, |
6192 | { "getExtension", &xc_getExtension }, | 6226 | { "getExtension", &xc_getExtension }, |
6193 | { "getExtensionCount", &xc_getExtensionCount }, | 6227 | { "getExtensionCount", &xc_getExtensionCount }, |
6228 | { "getOCSP", &xc_getOCSP }, | ||
6194 | { "isIssuedBy", &xc_isIssuedBy }, | 6229 | { "isIssuedBy", &xc_isIssuedBy }, |
6195 | { "getPublicKey", &xc_getPublicKey }, | 6230 | { "getPublicKey", &xc_getPublicKey }, |
6196 | { "setPublicKey", &xc_setPublicKey }, | 6231 | { "setPublicKey", &xc_setPublicKey }, |