mirror of
https://github.com/brunoos/luasec.git
synced 2024-11-08 06:28:26 +01:00
Some adjusts to OpenSSL 1.1.1 with --api=1.1.0
This commit is contained in:
parent
3490d8d1c0
commit
8ef33e33cf
14
src/compat.h
14
src/compat.h
@ -10,12 +10,16 @@
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define LSEC_API __declspec(dllexport)
|
||||
#else
|
||||
#define LSEC_API extern
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if (LUA_VERSION_NUM == 501)
|
||||
|
||||
#define luaL_testudata(L, ud, tname) lsec_testudata(L, ud, tname)
|
||||
@ -30,8 +34,18 @@
|
||||
#define setfuncs(L, R) luaL_setfuncs(L, R, 0)
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x1010000fL))
|
||||
#define LSEC_ENABLE_DANE
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !((defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x2070000fL)) || (OPENSSL_VERSION_NUMBER < 0x1010000fL))
|
||||
#define LSEC_API_OPENSSL_1_1_0
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
|
@ -614,7 +614,9 @@ static int set_curves_list(lua_State *L)
|
||||
return 2;
|
||||
}
|
||||
|
||||
#if defined(LIBRESSL_VERSION_NUMBER) || !defined(LSEC_API_OPENSSL_1_1_0)
|
||||
(void)SSL_CTX_set_ecdh_auto(ctx, 1);
|
||||
#endif
|
||||
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/x509_vfy.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/dh.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
@ -32,7 +33,7 @@
|
||||
#include "ssl.h"
|
||||
|
||||
|
||||
#if (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL) || (OPENSSL_VERSION_NUMBER < 0x1010000fL)
|
||||
#ifndef LSEC_API_OPENSSL_1_1_0
|
||||
#define SSL_is_server(s) (s->server)
|
||||
#define SSL_up_ref(ssl) CRYPTO_add(&(ssl)->references, 1, CRYPTO_LOCK_SSL)
|
||||
#define X509_up_ref(c) CRYPTO_add(&c->references, 1, CRYPTO_LOCK_X509)
|
||||
@ -912,7 +913,7 @@ static luaL_Reg funcs[] = {
|
||||
*/
|
||||
LSEC_API int luaopen_ssl_core(lua_State *L)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER<0x10100000L
|
||||
#ifndef LSEC_API_OPENSSL_1_1_0
|
||||
/* Initialize SSL */
|
||||
if (!SSL_library_init()) {
|
||||
lua_pushstring(L, "unable to initialize SSL library");
|
||||
|
21
src/x509.c
21
src/x509.c
@ -33,18 +33,10 @@
|
||||
#include "x509.h"
|
||||
|
||||
|
||||
/*
|
||||
* ASN1_STRING_data is deprecated in OpenSSL 1.1.0
|
||||
*/
|
||||
#if OPENSSL_VERSION_NUMBER>=0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
#define LSEC_ASN1_STRING_data(x) ASN1_STRING_get0_data(x)
|
||||
#else
|
||||
#define LSEC_ASN1_STRING_data(x) ASN1_STRING_data(x)
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
#define X509_get0_notBefore X509_get_notBefore
|
||||
#define X509_get0_notAfter X509_get_notAfter
|
||||
#ifndef LSEC_API_OPENSSL_1_1_0
|
||||
#define X509_get0_notBefore X509_get_notBefore
|
||||
#define X509_get0_notAfter X509_get_notAfter
|
||||
#define ASN1_STRING_get0_data ASN1_STRING_data
|
||||
#endif
|
||||
|
||||
static const char* hex_tab = "0123456789abcdef";
|
||||
@ -161,8 +153,7 @@ static void push_asn1_string(lua_State* L, ASN1_STRING *string, int encode)
|
||||
}
|
||||
switch (encode) {
|
||||
case LSEC_AI5_STRING:
|
||||
lua_pushlstring(L, (char*)LSEC_ASN1_STRING_data(string),
|
||||
ASN1_STRING_length(string));
|
||||
lua_pushlstring(L, (char*)ASN1_STRING_get0_data(string), ASN1_STRING_length(string));
|
||||
break;
|
||||
case LSEC_UTF8_STRING:
|
||||
len = ASN1_STRING_to_UTF8(&data, string);
|
||||
@ -197,7 +188,7 @@ static void push_asn1_ip(lua_State *L, ASN1_STRING *string)
|
||||
{
|
||||
int af;
|
||||
char dst[INET6_ADDRSTRLEN];
|
||||
unsigned char *ip = (unsigned char*)LSEC_ASN1_STRING_data(string);
|
||||
unsigned char *ip = (unsigned char*)ASN1_STRING_get0_data(string);
|
||||
switch(ASN1_STRING_length(string)) {
|
||||
case 4:
|
||||
af = AF_INET;
|
||||
|
Loading…
Reference in New Issue
Block a user