diff options
author | daurnimator <quae@daurnimator.com> | 2018-05-29 11:59:54 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-05-29 13:47:51 +1000 |
commit | c2505e13f50232c561b156ff0b1e14db8d616b73 (patch) | |
tree | 7fa9e56fb865d0039a65183b7a95e2cb77aab4b7 /src | |
parent | 6aaf6adfe40e629ead457f2696fa3d8139b59883 (diff) | |
download | luaossl-c2505e13f50232c561b156ff0b1e14db8d616b73.tar.gz luaossl-c2505e13f50232c561b156ff0b1e14db8d616b73.tar.bz2 luaossl-c2505e13f50232c561b156ff0b1e14db8d616b73.zip |
src/openssl.c: Add ssl:getCertificate()
It uses X509_dup to match :setCertificate().
Note that this differs from ssl:getPeerCertificate() which does *not* dup().
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 8efe6f7..860b8a0 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -9186,6 +9186,19 @@ static int ssl_setPrivateKey(lua_State *L) { } /* ssl_setPrivateKey() */ +static int ssl_getCertificate(lua_State *L) { + SSL *ssl = checksimple(L, 1, SSL_CLASS); + X509 *x509; + + if (!(x509 = SSL_get_certificate(ssl))) + return 0; + + xc_dup(L, x509); + + return 1; +} /* ssl_getCertificate() */ + + static int ssl_getPeerCertificate(lua_State *L) { SSL *ssl = checksimple(L, 1, SSL_CLASS); X509 **x509 = prepsimple(L, X509_CERT_CLASS); @@ -9520,6 +9533,7 @@ static const auxL_Reg ssl_methods[] = { { "getVerifyResult", &ssl_getVerifyResult }, { "setCertificate", &ssl_setCertificate }, { "setPrivateKey", &ssl_setPrivateKey }, + { "getCertificate", &ssl_getCertificate }, { "getPeerCertificate", &ssl_getPeerCertificate }, { "getPeerChain", &ssl_getPeerChain }, { "getCipherInfo", &ssl_getCipherInfo }, |