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>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define LSEC_API __declspec(dllexport)
|
#define LSEC_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define LSEC_API extern
|
#define LSEC_API extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if (LUA_VERSION_NUM == 501)
|
#if (LUA_VERSION_NUM == 501)
|
||||||
|
|
||||||
#define luaL_testudata(L, ud, tname) lsec_testudata(L, ud, tname)
|
#define luaL_testudata(L, ud, tname) lsec_testudata(L, ud, tname)
|
||||||
@ -30,8 +34,18 @@
|
|||||||
#define setfuncs(L, R) luaL_setfuncs(L, R, 0)
|
#define setfuncs(L, R) luaL_setfuncs(L, R, 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x1010000fL))
|
#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x1010000fL))
|
||||||
#define LSEC_ENABLE_DANE
|
#define LSEC_ENABLE_DANE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if !((defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x2070000fL)) || (OPENSSL_VERSION_NUMBER < 0x1010000fL))
|
||||||
|
#define LSEC_API_OPENSSL_1_1_0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -614,7 +614,9 @@ static int set_curves_list(lua_State *L)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(LIBRESSL_VERSION_NUMBER) || !defined(LSEC_API_OPENSSL_1_1_0)
|
||||||
(void)SSL_CTX_set_ecdh_auto(ctx, 1);
|
(void)SSL_CTX_set_ecdh_auto(ctx, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
lua_pushboolean(L, 1);
|
lua_pushboolean(L, 1);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
#include <openssl/x509_vfy.h>
|
#include <openssl/x509_vfy.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/dh.h>
|
||||||
|
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
@ -32,7 +33,7 @@
|
|||||||
#include "ssl.h"
|
#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_is_server(s) (s->server)
|
||||||
#define SSL_up_ref(ssl) CRYPTO_add(&(ssl)->references, 1, CRYPTO_LOCK_SSL)
|
#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)
|
#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)
|
LSEC_API int luaopen_ssl_core(lua_State *L)
|
||||||
{
|
{
|
||||||
#if OPENSSL_VERSION_NUMBER<0x10100000L
|
#ifndef LSEC_API_OPENSSL_1_1_0
|
||||||
/* Initialize SSL */
|
/* Initialize SSL */
|
||||||
if (!SSL_library_init()) {
|
if (!SSL_library_init()) {
|
||||||
lua_pushstring(L, "unable to initialize SSL library");
|
lua_pushstring(L, "unable to initialize SSL library");
|
||||||
|
17
src/x509.c
17
src/x509.c
@ -33,18 +33,10 @@
|
|||||||
#include "x509.h"
|
#include "x509.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
#ifndef LSEC_API_OPENSSL_1_1_0
|
||||||
* 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_notBefore X509_get_notBefore
|
||||||
#define X509_get0_notAfter X509_get_notAfter
|
#define X509_get0_notAfter X509_get_notAfter
|
||||||
|
#define ASN1_STRING_get0_data ASN1_STRING_data
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* hex_tab = "0123456789abcdef";
|
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) {
|
switch (encode) {
|
||||||
case LSEC_AI5_STRING:
|
case LSEC_AI5_STRING:
|
||||||
lua_pushlstring(L, (char*)LSEC_ASN1_STRING_data(string),
|
lua_pushlstring(L, (char*)ASN1_STRING_get0_data(string), ASN1_STRING_length(string));
|
||||||
ASN1_STRING_length(string));
|
|
||||||
break;
|
break;
|
||||||
case LSEC_UTF8_STRING:
|
case LSEC_UTF8_STRING:
|
||||||
len = ASN1_STRING_to_UTF8(&data, 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;
|
int af;
|
||||||
char dst[INET6_ADDRSTRLEN];
|
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)) {
|
switch(ASN1_STRING_length(string)) {
|
||||||
case 4:
|
case 4:
|
||||||
af = AF_INET;
|
af = AF_INET;
|
||||||
|
Loading…
Reference in New Issue
Block a user