diff options
| author | daurnimator <quae@daurnimator.com> | 2016-11-15 11:15:24 +1100 |
|---|---|---|
| committer | daurnimator <quae@daurnimator.com> | 2016-12-09 02:56:41 +1100 |
| commit | 043257dd0c0b7ebd7a577a9fceaecb1c2910f144 (patch) | |
| tree | 42ad1a78e3a77baaee725ba332fdd4e2816806c6 | |
| parent | 569d057d3e26b5a19c5808edd47e221acc9ed61f (diff) | |
| download | luaossl-043257dd0c0b7ebd7a577a9fceaecb1c2910f144.tar.gz luaossl-043257dd0c0b7ebd7a577a9fceaecb1c2910f144.tar.bz2 luaossl-043257dd0c0b7ebd7a577a9fceaecb1c2910f144.zip | |
openssl.ssl: Add ssl:setParam() and ssl:getParam()
| -rw-r--r-- | src/openssl.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index e6ae71d..f0b75ae 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
| @@ -7979,6 +7979,38 @@ static int ssl_clearOptions(lua_State *L) { | |||
| 7979 | } /* ssl_clearOptions() */ | 7979 | } /* ssl_clearOptions() */ |
| 7980 | 7980 | ||
| 7981 | 7981 | ||
| 7982 | static int ssl_setParam(lua_State *L) { | ||
| 7983 | SSL *ssl = checksimple(L, 1, SSL_CLASS); | ||
| 7984 | X509_VERIFY_PARAM *xp = checksimple(L, 2, X509_VERIFY_PARAM_CLASS); | ||
| 7985 | |||
| 7986 | if (!SSL_set1_param(ssl, xp)) | ||
| 7987 | return auxL_error(L, auxL_EOPENSSL, "ssl:setParam"); | ||
| 7988 | |||
| 7989 | lua_pushboolean(L, 1); | ||
| 7990 | |||
| 7991 | return 1; | ||
| 7992 | } /* ssl_setParam() */ | ||
| 7993 | |||
| 7994 | |||
| 7995 | static int ssl_getParam(lua_State *L) { | ||
| 7996 | SSL *ssl = checksimple(L, 1, SSL_CLASS); | ||
| 7997 | X509_VERIFY_PARAM **ud, *from; | ||
| 7998 | |||
| 7999 | /* X509_VERIFY_PARAM is not refcounted; create a new object and copy into it. */ | ||
| 8000 | ud = prepsimple(L, X509_VERIFY_PARAM_CLASS); | ||
| 8001 | if (!(*ud = X509_VERIFY_PARAM_new())) | ||
| 8002 | return auxL_error(L, auxL_EOPENSSL, "ssl:getParam"); | ||
| 8003 | |||
| 8004 | from = SSL_get0_param(ssl); | ||
| 8005 | |||
| 8006 | if (!(X509_VERIFY_PARAM_set1(*ud, from))) | ||
| 8007 | /* Note: openssl doesn't set an error as it should for some cases */ | ||
| 8008 | return auxL_error(L, auxL_EOPENSSL, "ssl:getParam"); | ||
| 8009 | |||
| 8010 | return 1; | ||
| 8011 | } /* ssl_getParam() */ | ||
| 8012 | |||
| 8013 | |||
| 7982 | static int ssl_getPeerCertificate(lua_State *L) { | 8014 | static int ssl_getPeerCertificate(lua_State *L) { |
| 7983 | SSL *ssl = checksimple(L, 1, SSL_CLASS); | 8015 | SSL *ssl = checksimple(L, 1, SSL_CLASS); |
| 7984 | X509 **x509 = prepsimple(L, X509_CERT_CLASS); | 8016 | X509 **x509 = prepsimple(L, X509_CERT_CLASS); |
| @@ -8166,6 +8198,8 @@ static const auxL_Reg ssl_methods[] = { | |||
| 8166 | { "setOptions", &ssl_setOptions }, | 8198 | { "setOptions", &ssl_setOptions }, |
| 8167 | { "getOptions", &ssl_getOptions }, | 8199 | { "getOptions", &ssl_getOptions }, |
| 8168 | { "clearOptions", &ssl_clearOptions }, | 8200 | { "clearOptions", &ssl_clearOptions }, |
| 8201 | { "setParam", &ssl_setParam }, | ||
| 8202 | { "getParam", &ssl_getParam }, | ||
| 8169 | { "getPeerCertificate", &ssl_getPeerCertificate }, | 8203 | { "getPeerCertificate", &ssl_getPeerCertificate }, |
| 8170 | { "getPeerChain", &ssl_getPeerChain }, | 8204 | { "getPeerChain", &ssl_getPeerChain }, |
| 8171 | { "getCipherInfo", &ssl_getCipherInfo }, | 8205 | { "getCipherInfo", &ssl_getCipherInfo }, |
