mirror of
https://github.com/brunoos/luasec.git
synced 2024-12-26 20:48:22 +01:00
Compatibility with OpenSSL 1.1.0
Defining macros X509_up_ref() and SSL_is_server to use the same API of OpenSSL 1.1.0.
This commit is contained in:
parent
80a527d630
commit
4889830d53
@ -35,10 +35,6 @@ typedef const SSL_METHOD LSEC_SSL_METHOD;
|
||||
typedef SSL_METHOD LSEC_SSL_METHOD;
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER>=0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
#define SSLv23_method() TLS_method()
|
||||
#endif
|
||||
|
||||
/*-- Compat - Lua 5.1 --------------------------------------------------------*/
|
||||
|
||||
#if (LUA_VERSION_NUM == 501)
|
||||
|
15
src/ssl.c
15
src/ssl.c
@ -31,6 +31,13 @@
|
||||
#include "context.h"
|
||||
#include "ssl.h"
|
||||
|
||||
|
||||
#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER<0x10100000L
|
||||
#define SSL_is_server(s) (s->server)
|
||||
#define X509_up_ref(c) CRYPTO_add(&c->references, 1, CRYPTO_LOCK_X509)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Underline socket error.
|
||||
*/
|
||||
@ -460,7 +467,7 @@ static int meth_getpeercertificate(lua_State *L)
|
||||
/* In a server-context, the stack doesn't contain the peer cert,
|
||||
* so adjust accordingly.
|
||||
*/
|
||||
if (ssl->ssl->server)
|
||||
if (SSL_is_server(ssl->ssl))
|
||||
--n;
|
||||
certs = SSL_get_peer_cert_chain(ssl->ssl);
|
||||
if (n >= sk_X509_num(certs)) {
|
||||
@ -470,7 +477,7 @@ static int meth_getpeercertificate(lua_State *L)
|
||||
cert = sk_X509_value(certs, n);
|
||||
/* Increment the reference counting of the object. */
|
||||
/* See SSL_get_peer_certificate() source code. */
|
||||
CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509);
|
||||
X509_up_ref(cert);
|
||||
lsec_pushx509(L, cert);
|
||||
return 1;
|
||||
}
|
||||
@ -492,7 +499,7 @@ static int meth_getpeerchain(lua_State *L)
|
||||
return 2;
|
||||
}
|
||||
lua_newtable(L);
|
||||
if (ssl->ssl->server) {
|
||||
if (SSL_is_server(ssl->ssl)) {
|
||||
lsec_pushx509(L, SSL_get_peer_certificate(ssl->ssl));
|
||||
lua_rawseti(L, -2, idx++);
|
||||
}
|
||||
@ -502,7 +509,7 @@ static int meth_getpeerchain(lua_State *L)
|
||||
cert = sk_X509_value(certs, i);
|
||||
/* Increment the reference counting of the object. */
|
||||
/* See SSL_get_peer_certificate() source code. */
|
||||
CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509);
|
||||
X509_up_ref(cert);
|
||||
lsec_pushx509(L, cert);
|
||||
lua_rawseti(L, -2, idx++);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user