Browse Source

lua-openssl: upgrade to version 0.7.1

This version brings compatibility with openssl 1.1.0

Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
lilik-openwrt-22.03
Eneas U de Queiroz 7 years ago
parent
commit
ca7b00b469
5 changed files with 83 additions and 150 deletions
  1. +2
    -2
      lang/lua-openssl/Makefile
  2. +50
    -87
      lang/lua-openssl/patches/0001-Revise-Makefile.patch
  3. +0
    -41
      lang/lua-openssl/patches/0020-support-OPENSSL_NO_SSL3_METHOD.patch
  4. +31
    -0
      lang/lua-openssl/patches/0020-use-X509_REQ_to_X509-in-openssl-1.1.patch
  5. +0
    -20
      lang/lua-openssl/patches/0030-support-OPENSSL_NO_COMP.patch

+ 2
- 2
lang/lua-openssl/Makefile View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=lua-openssl PKG_NAME:=lua-openssl
PKG_VERSION:=0.6.0
PKG_VERSION:=0.7.1
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=Amnon Paz <pazamnon@gmail.com> PKG_MAINTAINER:=Amnon Paz <pazamnon@gmail.com>
PKG_LICENSE:=MIT PKG_LICENSE:=MIT
@ -17,7 +17,7 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_MIRROR_HASH:=33de8fa469f66bbf6df09c4ba4e3386c0613cc061f5adff0928d532af6905773 PKG_MIRROR_HASH:=33de8fa469f66bbf6df09c4ba4e3386c0613cc061f5adff0928d532af6905773
PKG_SOURCE_URL:=https://github.com/zhaozg/lua-openssl.git PKG_SOURCE_URL:=https://github.com/zhaozg/lua-openssl.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=1b950e6ff8617205cda1a1b612637ef21b9daf96
PKG_SOURCE_VERSION:=b104bbe914d279276560f188854036075b99f724
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk


+ 50
- 87
lang/lua-openssl/patches/0001-Revise-Makefile.patch View File

@ -1,13 +1,13 @@
diff --git a/Makefile b/Makefile
index 6cb1176..6605879 100644
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -1,85 +1,45 @@
-T=openssl
-
@@ -1,58 +1,36 @@
T=openssl
+.PHONY: install clean
-PREFIX ?=/usr/local -PREFIX ?=/usr/local
-LIB_OPTION ?= -shared -LIB_OPTION ?= -shared
-
+PKGC ?= pkg-config
-#Lua auto detect -#Lua auto detect
-LUA_VERSION ?= $(shell pkg-config luajit --print-provides) -LUA_VERSION ?= $(shell pkg-config luajit --print-provides)
-ifeq ($(LUA_VERSION),) ############ Not use luajit -ifeq ($(LUA_VERSION),) ############ Not use luajit
@ -21,10 +21,15 @@ index 6cb1176..6605879 100644
-LUA_LIBS ?= $(shell pkg-config luajit --libs) -LUA_LIBS ?= $(shell pkg-config luajit --libs)
-LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV) -LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
-endif -endif
-
+LIB_OPTION = -shared
-#OS auto detect -#OS auto detect
-SYS := $(shell gcc -dumpmachine) -SYS := $(shell gcc -dumpmachine)
-
+# lua's package config can be under various names
+LUAPKGC := $(shell for pc in lua lua5.1 lua5.2 lua5.3; do \
+ $(PKGC) --exists $$pc && echo $$pc && break; \
+ done)
-ifneq (, $(findstring linux, $(SYS))) -ifneq (, $(findstring linux, $(SYS)))
-# Do linux things -# Do linux things
-LDFLAGS = -fPIC -lrt -ldl -LDFLAGS = -fPIC -lrt -ldl
@ -35,8 +40,19 @@ index 6cb1176..6605879 100644
-ifneq (, $(findstring apple, $(SYS))) -ifneq (, $(findstring apple, $(SYS)))
-# Do darwin things -# Do darwin things
-LDFLAGS = -fPIC -lrt -ldl -LDFLAGS = -fPIC -lrt -ldl
-OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
-OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
+BUILD_DIR = $(shell pwd)
+
+# LUA include/libraries build flags
+#LUAV ?= $(shell lua -e "_,_,v=string.find(_VERSION,'Lua (.+)');print(v)")
+LUA_LIBDIR := $(shell $(PKGC) --variable=libdir $(LUAPKGC))
+LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
+LUA_LIBS := $(shell $(PKGC) --libs-only-L $(LUAPKGC))
+#LUA_LIBDIR ?= $(PREFIX)/lib/lua/$(LUAV)
+
+# openssl include/libraries build flags
+LDFLAGS += -lrt -ldl $(OPENSSL_LIBS) $(LUA_LIBS)
OPENSSL_LIBS ?= $(shell pkg-config openssl --libs)
OPENSSL_CFLAGS ?= $(shell pkg-config openssl --cflags)
-CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS) -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
-endif -endif
-ifneq (, $(findstring mingw, $(SYS))) -ifneq (, $(findstring mingw, $(SYS)))
@ -53,83 +69,30 @@ index 6cb1176..6605879 100644
-CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS) -CFLAGS = -fPIC $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
-endif -endif
-#custome config -#custome config
-ifeq (.config, $(wildcard .config))
-include .config
-endif
-
+# openssl include/libraries build flags
+LOCAL_INCLUDE = -I$(BUILD_DIR)/deps
+CFLAGS += -fPIC -DPTHREADS $(LOCAL_INCLUDE) $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
ifeq (.config, $(wildcard .config))
include .config
endif
-LIBNAME= $T.so.$V -LIBNAME= $T.so.$V
-
-#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X
-
-# Compilation directives
-WARN_MOST = -Wall -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic
-WARN = -Wall -Wno-unused-value
-WARN_MIN =
-CFLAGS += $(WARN_MIN) -DPTHREADS
-CC= gcc -g $(CFLAGS) -Ideps
-
-
-OBJS=src/asn1.o src/auxiliar.o src/bio.o src/cipher.o src/cms.o src/compat.o src/crl.o src/csr.o src/dh.o src/digest.o src/dsa.o \
-src/ec.o src/engine.o src/hmac.o src/lbn.o src/lhash.o src/misc.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o \
-src/pkey.o src/rsa.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o src/xalgor.o src/callback.o
-
+LIBNAME= $T.so
#LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X
@@ -68,11 +46,12 @@ OBJS=src/asn1.o src/auxiliar.o src/bio.o
src/ec.o src/engine.o src/hmac.o src/lbn.o src/lhash.o src/misc.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o \
src/pkey.o src/rsa.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o src/xalgor.o src/callback.o
-.c.o: -.c.o:
- $(CC) -c -o $@ $? - $(CC) -c -o $@ $?
-
-all: $T.so
- echo $(SYS)
-
-$T.so: $(OBJS)
- MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(OPENSSL_LIBS) $(LUA_LIBS) $(LDFLAGS)
-
-install: all
- mkdir -p $(LUA_LIBDIR)
- cp $T.so $(LUA_LIBDIR)
-
-clean:
- rm -f $T.so $(OBJS)
+.PHONY: install clean
+
+PKGC ?= pkg-config
+
+LIBNAME = openssl.so
+LIB_OPTION = -shared
+
+# lua's package config can be under various names
+LUAPKGC := $(shell for pc in lua lua5.1 lua5.2 lua5.3; do \
+ $(PKGC) --exists $$pc && echo $$pc && break; \
+ done)
+
+BUILD_DIR = $(shell pwd)
+
+# LUA include/libraries build flags
+LUA_LIBDIR := $(shell $(PKGC) --variable=libdir $(LUAPKGC))
+LUA_CFLAGS := $(shell $(PKGC) --cflags $(LUAPKGC))
+LUA_LIBS := $(shell $(PKGC) --libs-only-L $(LUAPKGC))
+
+# openssl include/libraries build flags
+OPENSSL_LIBS = $(shell $(PKGC) openssl --libs)
+OPENSSL_CFLAGS = $(shell $(PKGC) openssl --cflags)
+
+# openssl include/libraries build flags
+LOCAL_INCLUDE = -I$(BUILD_DIR)/deps
+
+CFLAGS += -fPIC -DPTHREADS -g $(LOCAL_INCLUDE) $(OPENSSL_CFLAGS) $(LUA_CFLAGS)
+LDFLAGS += -lrt -ldl $(OPENSSL_LIBS) $(LUA_LIBS)
+
+OBJS = src/asn1.o src/auxiliar.o src/bio.o src/cipher.o src/cms.o src/compat.o src/crl.o src/csr.o src/dh.o src/digest.o src/dsa.o src/ec.o src/engine.o src/hmac.o src/lbn.o src/lhash.o src/misc.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o src/pkey.o src/rsa.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o src/xalgor.o src/callback.o
+
+all: clean $(LIBNAME)
+
+$(LIBNAME): $(OBJS)
+ $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+install: all
+ mkdir -p $(LUA_LIBDIR)
+ cp $(LIBNAME) $(LUA_LIBDIR)
+
+clean:
+ rm -f $(LIBNAME) $(OBJS)
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@
all: $T.so
echo $(SYS)
+ $(CC) $(LDFLAGS) $(LIB_OPTION) $(OBJS) -o $@
$T.so: $(OBJS)
MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) $(CFLAGS) $(LIB_OPTION) -o $T.so $(OBJS) $(OPENSSL_LIBS) $(LUA_LIBS) $(LDFLAGS)

+ 0
- 41
lang/lua-openssl/patches/0020-support-OPENSSL_NO_SSL3_METHOD.patch View File

@ -1,41 +0,0 @@
--- lua-openssl-0.6.0.old/src/ssl.c 2016-09-19 08:30:43.735075695 +0200
+++ lua-openssl-0.6.0/src/ssl.c 2016-09-19 09:02:45.733813437 +0200
@@ -24,12 +24,17 @@
SSL_METHOD* method = NULL;
const char* ciphers;
SSL_CTX* ctx;
- if (strcmp(meth, "SSLv3") == 0)
+ if (0);
+
+#ifndef OPENSSL_NO_SSL3
+ else if (strcmp(meth, "SSLv3") == 0)
method = SSLv3_method(); /* SSLv3 */
else if (strcmp(meth, "SSLv3_server") == 0)
method = SSLv3_server_method(); /* SSLv3 */
else if (strcmp(meth, "SSLv3_client") == 0)
method = SSLv3_client_method(); /* SSLv3 */
+#endif
+
else if (strcmp(meth, "SSLv23") == 0)
method = SSLv23_method(); /* SSLv3 but can rollback to v2 */
else if (strcmp(meth, "SSLv23_server") == 0)
@@ -79,15 +84,15 @@
#endif
else
luaL_error(L, "#1:%s not supported\n"
- "Maybe SSLv3 SSLv23 TLSv1 TLSv1_1 TLSv1_2 DTLSv1 [SSLv2], option followed by _client or _server\n",
- "default is SSLv3",
+ "Maybe [SSLv3] SSLv23 TLSv1 TLSv1_1 TLSv1_2 DTLSv1 [SSLv2], option followed by _client or _server\n",
+ "default is TLSv1",
meth);
ciphers = luaL_optstring(L, 2, SSL_DEFAULT_CIPHER_LIST);
ctx = SSL_CTX_new(method);
if (!ctx)
luaL_error(L, "#1:%s not supported\n"
- "Maybe SSLv3 SSLv23 TLSv1 TLSv1_1 TLSv1_2 DTLSv1 [SSLv2], option followed by _client or _server\n",
- "default is SSLv3",
+ "Maybe [SSLv3] SSLv23 TLSv1 TLSv1_1 TLSv1_2 DTLSv1 [SSLv2], option followed by _client or _server\n",
+ "default is TLSv1",
meth);
openssl_newvalue(L, ctx);
SSL_CTX_set_cipher_list(ctx, ciphers);

+ 31
- 0
lang/lua-openssl/patches/0020-use-X509_REQ_to_X509-in-openssl-1.1.patch View File

@ -0,0 +1,31 @@
--- a/src/csr.c
+++ b/src/csr.c
@@ -38,7 +38,7 @@ static LUA_FUNCTION(openssl_csr_read)
return openssl_pushresult(L, 0);
}
-
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
static X509 *X509_REQ_to_X509_ex(X509_REQ *r, int days, EVP_PKEY *pkey, const EVP_MD* md)
{
X509 *ret = NULL;
@@ -91,14 +91,19 @@ static X509 *X509_REQ_to_X509_ex(X509_RE
}
return (ret);
}
+#endif
static LUA_FUNCTION(openssl_csr_to_x509)
{
X509_REQ * csr = CHECK_OBJECT(1, X509_REQ, "openssl.x509_req");
EVP_PKEY * pkey = CHECK_OBJECT(2, EVP_PKEY, "openssl.evp_pkey");
int days = luaL_optint(L, 3, 365);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
const EVP_MD* md = get_digest(L, 4, "sha256");
X509* cert = X509_REQ_to_X509_ex(csr, days, pkey, md);
+#else
+ X509* cert = X509_REQ_to_X509(csr, days, pkey);
+#endif
if (cert)
{
PUSH_OBJECT(cert, "openssl.x509");

+ 0
- 20
lang/lua-openssl/patches/0030-support-OPENSSL_NO_COMP.patch View File

@ -1,20 +0,0 @@
--- lua-openssl-0.6.0.old/src/ssl.c 2016-09-19 08:30:43.735075695 +0200
+++ lua-openssl-0.6.0/src/ssl.c 2016-09-19 08:48:37.393737125 +0200
@@ -1245,7 +1250,7 @@
lua_pushinteger(L, st);
return 2;
}
-#ifndef LIBRESSL_VERSION_NUMBER
+#if !defined(OPENSSL_NO_COMP) && !defined(LIBRESSL_VERSION_NUMBER)
static int openssl_ssl_current_compression(lua_State *L)
{
SSL* s = CHECK_OBJECT(1, SSL, "openssl.ssl");
@@ -1803,7 +1808,7 @@
{"getfd", openssl_ssl_getfd},
{"current_cipher", openssl_ssl_current_cipher},
-#ifndef LIBRESSL_VERSION_NUMBER
+#if !defined(OPENSSL_NO_COMP) && !defined(LIBRESSL_VERSION_NUMBER)
{"current_compression", openssl_ssl_current_compression},
#endif
{"getpeerverification", openssl_ssl_getpeerverification},

Loading…
Cancel
Save