summaryrefslogtreecommitdiff
path: root/src/openssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/openssl.c')
-rw-r--r--src/openssl.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index ac053fd..a3e5637 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -253,6 +253,14 @@
253#define HAVE_SSL_CTX_GET0_PARAM OPENSSL_PREREQ(1,0,2) 253#define HAVE_SSL_CTX_GET0_PARAM OPENSSL_PREREQ(1,0,2)
254#endif 254#endif
255 255
256#ifndef HAVE_SSL_CTX_SET_CURVES_LIST
257#define HAVE_SSL_CTX_SET_CURVES_LIST (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,5,1))
258#endif
259
260#ifndef HAVE_SSL_CTX_SET_ECDH_AUTO
261#define HAVE_SSL_CTX_SET_ECDH_AUTO ((OPENSSL_PREREQ(1,0,2) && !OPENSSL_PREREQ(1,1,0)) || LIBRESSL_PREREQ(2,1,2))
262#endif
263
256#ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS 264#ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS
257#define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3)) 265#define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3))
258#endif 266#endif
@@ -297,6 +305,10 @@
297#define HAVE_SSL_SET_ALPN_PROTOS HAVE_SSL_CTX_SET_ALPN_PROTOS 305#define HAVE_SSL_SET_ALPN_PROTOS HAVE_SSL_CTX_SET_ALPN_PROTOS
298#endif 306#endif
299 307
308#ifndef HAVE_SSL_SET_CURVES_LIST
309#define HAVE_SSL_SET_CURVES_LIST (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,5,1))
310#endif
311
300#ifndef HAVE_SSL_SET1_PARAM 312#ifndef HAVE_SSL_SET1_PARAM
301#define HAVE_SSL_SET1_PARAM OPENSSL_PREREQ(1,0,2) 313#define HAVE_SSL_SET1_PARAM OPENSSL_PREREQ(1,0,2)
302#endif 314#endif
@@ -7824,6 +7836,15 @@ static int sx_new(lua_State *L) {
7824 7836
7825 SSL_CTX_set_options(*ud, options); 7837 SSL_CTX_set_options(*ud, options);
7826 7838
7839#if HAVE_SSL_CTX_SET_ECDH_AUTO
7840 /* OpenSSL 1.0.2 introduced SSL_CTX_set_ecdh_auto to automatically select
7841 * from the curves set via SSL_CTX_set1_curves_list. However as of OpenSSL
7842 * 1.1.0, the functionality was turned on permanently and the option
7843 * removed. */
7844 if (!SSL_CTX_set_ecdh_auto(*ud, 1))
7845 return auxL_error(L, auxL_EOPENSSL, "ssl.context.new");
7846#endif
7847
7827 return 1; 7848 return 1;
7828} /* sx_new() */ 7849} /* sx_new() */
7829 7850
@@ -7999,6 +8020,21 @@ static int sx_setCipherList(lua_State *L) {
7999} /* sx_setCipherList() */ 8020} /* sx_setCipherList() */
8000 8021
8001 8022
8023#if HAVE_SSL_CTX_SET_CURVES_LIST
8024static int sx_setCurvesList(lua_State *L) {
8025 SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS);
8026 const char *curves = luaL_checkstring(L, 2);
8027
8028 if (!SSL_CTX_set1_curves_list(ctx, curves))
8029 return auxL_error(L, auxL_EOPENSSL, "ssl.context:setCurvesList");
8030
8031 lua_pushboolean(L, 1);
8032
8033 return 1;
8034} /* sx_setCurvesList() */
8035#endif
8036
8037
8002static int sx_setEphemeralKey(lua_State *L) { 8038static int sx_setEphemeralKey(lua_State *L) {
8003 SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); 8039 SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS);
8004 EVP_PKEY *key = checksimple(L, 2, PKEY_CLASS); 8040 EVP_PKEY *key = checksimple(L, 2, PKEY_CLASS);
@@ -8303,6 +8339,9 @@ static const auxL_Reg sx_methods[] = {
8303 { "setCertificate", &sx_setCertificate }, 8339 { "setCertificate", &sx_setCertificate },
8304 { "setPrivateKey", &sx_setPrivateKey }, 8340 { "setPrivateKey", &sx_setPrivateKey },
8305 { "setCipherList", &sx_setCipherList }, 8341 { "setCipherList", &sx_setCipherList },
8342#if HAVE_SSL_CTX_SET_CURVES_LIST
8343 { "setCurvesList", &sx_setCurvesList },
8344#endif
8306 { "setEphemeralKey", &sx_setEphemeralKey }, 8345 { "setEphemeralKey", &sx_setEphemeralKey },
8307#if HAVE_SSL_CTX_SET_ALPN_PROTOS 8346#if HAVE_SSL_CTX_SET_ALPN_PROTOS
8308 { "setAlpnProtos", &sx_setAlpnProtos }, 8347 { "setAlpnProtos", &sx_setAlpnProtos },
@@ -8627,6 +8666,21 @@ static int ssl_getCipherInfo(lua_State *L) {
8627} /* ssl_getCipherInfo() */ 8666} /* ssl_getCipherInfo() */
8628 8667
8629 8668
8669#if HAVE_SSL_SET_CURVES_LIST
8670static int ssl_setCurvesList(lua_State *L) {
8671 SSL *ssl = checksimple(L, 1, SSL_CLASS);
8672 const char *curves = luaL_checkstring(L, 2);
8673
8674 if (!SSL_set1_curves_list(ssl, curves))
8675 return auxL_error(L, auxL_EOPENSSL, "ssl:setCurvesList");
8676
8677 lua_pushboolean(L, 1);
8678
8679 return 1;
8680} /* ssl_setCurvesList() */
8681#endif
8682
8683
8630static int ssl_getHostName(lua_State *L) { 8684static int ssl_getHostName(lua_State *L) {
8631 SSL *ssl = checksimple(L, 1, SSL_CLASS); 8685 SSL *ssl = checksimple(L, 1, SSL_CLASS);
8632 const char *host; 8686 const char *host;
@@ -8881,6 +8935,9 @@ static const auxL_Reg ssl_methods[] = {
8881 { "getPeerCertificate", &ssl_getPeerCertificate }, 8935 { "getPeerCertificate", &ssl_getPeerCertificate },
8882 { "getPeerChain", &ssl_getPeerChain }, 8936 { "getPeerChain", &ssl_getPeerChain },
8883 { "getCipherInfo", &ssl_getCipherInfo }, 8937 { "getCipherInfo", &ssl_getCipherInfo },
8938#if HAVE_SSL_SET_CURVES_LIST
8939 { "setCurvesList", &ssl_setCurvesList },
8940#endif
8884 { "getHostName", &ssl_getHostName }, 8941 { "getHostName", &ssl_getHostName },
8885 { "setHostName", &ssl_setHostName }, 8942 { "setHostName", &ssl_setHostName },
8886 { "getVersion", &ssl_getVersion }, 8943 { "getVersion", &ssl_getVersion },