mirror of
https://github.com/brunoos/luasec.git
synced 2025-07-18 14:59:53 +02:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
df27c62f4c | |||
09691fe782 | |||
3a71559e13 | |||
3f04fd7529 | |||
d7161ca026 | |||
65ee83275b | |||
ef14b27a2c | |||
316bea078c | |||
79bbc0bc3e | |||
8cba350f37 | |||
eedebb2477 | |||
c1e28e9132 | |||
cdcf5fdb30 | |||
bdbc67b188 | |||
359151144b | |||
d6b2fd7d35 | |||
d5df315617 | |||
34252fb10a |
27
CHANGELOG
27
CHANGELOG
@ -1,3 +1,30 @@
|
|||||||
|
--------------------------------------------------------------------------------
|
||||||
|
LuaSec 1.1.0
|
||||||
|
---------------
|
||||||
|
This version includes:
|
||||||
|
|
||||||
|
* Fix missing DANE flag
|
||||||
|
* Remove unused parameter in https.lua
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
LuaSec 1.0.2
|
||||||
|
---------------
|
||||||
|
This version includes:
|
||||||
|
|
||||||
|
* Fix handle SSL_send SYSCALL error without errno
|
||||||
|
* Fix off by one in cert:validat(notafter)
|
||||||
|
* Fix meth_get_{sinagure => signature}_name function name
|
||||||
|
* Fix update the Lua state reference on the selected SSL context after SNI
|
||||||
|
* Fix ignore SSL_OP_BIT(n) macro and update option.c
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
LuaSec 1.0.1
|
||||||
|
---------------
|
||||||
|
This version includes:
|
||||||
|
|
||||||
|
|
||||||
|
* Fix luaL_buffinit() can use the stack and broke buffer_meth_receive()
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
LuaSec 1.0
|
LuaSec 1.0
|
||||||
---------------
|
---------------
|
||||||
|
4
INSTALL
4
INSTALL
@ -1,9 +1,9 @@
|
|||||||
LuaSec 1.0
|
LuaSec 1.1.0
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* OpenSSL options:
|
* OpenSSL options:
|
||||||
|
|
||||||
By default, this version includes options for OpenSSL 1.1.1.
|
By default, this version includes options for OpenSSL 3.0.0 beta2
|
||||||
|
|
||||||
If you need to generate the options for a different version of OpenSSL:
|
If you need to generate the options for a different version of OpenSSL:
|
||||||
|
|
||||||
|
4
LICENSE
4
LICENSE
@ -1,5 +1,5 @@
|
|||||||
LuaSec 1.0 license
|
LuaSec 1.1.0 license
|
||||||
Copyright (C) 2006-2021 Bruno Silvestre, UFG
|
Copyright (C) 2006-2022 Bruno Silvestre, UFG
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
LuaSec 1.0
|
LuaSec 1.1.0
|
||||||
===============
|
===============
|
||||||
LuaSec depends on OpenSSL, and integrates with LuaSocket to make it
|
LuaSec depends on OpenSSL, and integrates with LuaSocket to make it
|
||||||
easy to add secure connections to any Lua applications or scripts.
|
easy to add secure connections to any Lua applications or scripts.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package = "LuaSec"
|
package = "LuaSec"
|
||||||
version = "1.0-1"
|
version = "1.1.0-1"
|
||||||
source = {
|
source = {
|
||||||
url = "git://github.com/brunoos/luasec",
|
url = "git+https://github.com/brunoos/luasec",
|
||||||
tag = "v1.0",
|
tag = "v1.1.0",
|
||||||
}
|
}
|
||||||
description = {
|
description = {
|
||||||
summary = "A binding for OpenSSL library to provide TLS/SSL communication over LuaSocket.",
|
summary = "A binding for OpenSSL library to provide TLS/SSL communication over LuaSocket.",
|
10
src/compat.h
10
src/compat.h
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre
|
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -48,4 +48,10 @@
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if !defined(LIBRESSL_VERSION_NUMBER) && ((OPENSSL_VERSION_NUMBER & 0xFFFFF000L) == 0x10101000L)
|
||||||
|
#define LSEC_OPENSSL_1_1_1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
11
src/config.c
11
src/config.c
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre.
|
* Copyright (C) 2006-2022 Bruno Silvestre.
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -77,8 +77,15 @@ LSEC_API int luaopen_ssl_config(lua_State *L)
|
|||||||
#ifdef LSEC_ENABLE_DANE
|
#ifdef LSEC_ENABLE_DANE
|
||||||
// DANE
|
// DANE
|
||||||
lua_pushstring(L, "dane");
|
lua_pushstring(L, "dane");
|
||||||
|
#ifdef DANE_FLAG_NO_DANE_EE_NAMECHECKS
|
||||||
|
lua_createtable(L, 0, 1);
|
||||||
|
lua_pushstring(L, "no_ee_namechecks");
|
||||||
lua_pushboolean(L, 1);
|
lua_pushboolean(L, 1);
|
||||||
lua_rawset(L, -3);
|
lua_rawset(L, -3);
|
||||||
|
#else
|
||||||
|
lua_pushboolean(L, 1);
|
||||||
|
#endif
|
||||||
|
lua_rawset(L, -3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_EC
|
#ifndef OPENSSL_NO_EC
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2021 Kim Alvefur, Paul Aurich, Tobias Markmann,
|
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann,
|
||||||
* Matthew Wild.
|
* Matthew Wild.
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre.
|
* Copyright (C) 2006-2022 Bruno Silvestre.
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -17,6 +17,7 @@
|
|||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/x509v3.h>
|
#include <openssl/x509v3.h>
|
||||||
|
#include <openssl/x509_vfy.h>
|
||||||
#include <openssl/dh.h>
|
#include <openssl/dh.h>
|
||||||
|
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
@ -711,11 +712,31 @@ static int set_alpn_cb(lua_State *L)
|
|||||||
/*
|
/*
|
||||||
* DANE
|
* DANE
|
||||||
*/
|
*/
|
||||||
|
static int dane_options[] = {
|
||||||
|
/* TODO move into options.c
|
||||||
|
* however this symbol is not from openssl/ssl.h but rather from
|
||||||
|
* openssl/x509_vfy.h
|
||||||
|
* */
|
||||||
|
#ifdef DANE_FLAG_NO_DANE_EE_NAMECHECKS
|
||||||
|
DANE_FLAG_NO_DANE_EE_NAMECHECKS,
|
||||||
|
#endif
|
||||||
|
0
|
||||||
|
};
|
||||||
|
static const char *dane_option_names[] = {
|
||||||
|
#ifdef DANE_FLAG_NO_DANE_EE_NAMECHECKS
|
||||||
|
"no_ee_namechecks",
|
||||||
|
#endif
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
static int set_dane(lua_State *L)
|
static int set_dane(lua_State *L)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, i;
|
||||||
SSL_CTX *ctx = lsec_checkcontext(L, 1);
|
SSL_CTX *ctx = lsec_checkcontext(L, 1);
|
||||||
ret = SSL_CTX_dane_enable(ctx);
|
ret = SSL_CTX_dane_enable(ctx);
|
||||||
|
for (i = 2; ret > 0 && i <= lua_gettop(L); i++) {
|
||||||
|
ret = SSL_CTX_dane_set_flags(ctx, dane_options[luaL_checkoption(L, i, NULL, dane_option_names)]);
|
||||||
|
}
|
||||||
lua_pushboolean(L, (ret > 0));
|
lua_pushboolean(L, (ret > 0));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#define LSEC_CONTEXT_H
|
#define LSEC_CONTEXT_H
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre
|
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
4
src/ec.h
4
src/ec.h
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre
|
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
-- LuaSec 1.0
|
-- LuaSec 1.1.0
|
||||||
-- Copyright (C) 2009-2021 PUC-Rio
|
-- Copyright (C) 2009-2022 PUC-Rio
|
||||||
--
|
--
|
||||||
-- Author: Pablo Musa
|
-- Author: Pablo Musa
|
||||||
-- Author: Tomas Guisasola
|
-- Author: Tomas Guisasola
|
||||||
@ -18,8 +18,8 @@ local try = socket.try
|
|||||||
-- Module
|
-- Module
|
||||||
--
|
--
|
||||||
local _M = {
|
local _M = {
|
||||||
_VERSION = "1.0",
|
_VERSION = "1.1.0",
|
||||||
_COPYRIGHT = "LuaSec 1.0 - Copyright (C) 2009-2021 PUC-Rio",
|
_COPYRIGHT = "LuaSec 1.1.0 - Copyright (C) 2009-2022 PUC-Rio",
|
||||||
PORT = 443,
|
PORT = 443,
|
||||||
TIMEOUT = 60
|
TIMEOUT = 60
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ local function tcp(params)
|
|||||||
self.sock:sni(host)
|
self.sock:sni(host)
|
||||||
self.sock:settimeout(_M.TIMEOUT)
|
self.sock:settimeout(_M.TIMEOUT)
|
||||||
try(self.sock:dohandshake())
|
try(self.sock:dohandshake())
|
||||||
reg(self, getmetatable(self.sock))
|
reg(self)
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
return conn
|
return conn
|
||||||
|
@ -107,10 +107,16 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
|
|||||||
* object:receive() interface
|
* object:receive() interface
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
int buffer_meth_receive(lua_State *L, p_buffer buf) {
|
int buffer_meth_receive(lua_State *L, p_buffer buf) {
|
||||||
int err = IO_DONE, top = lua_gettop(L);
|
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
size_t size;
|
size_t size;
|
||||||
const char *part = luaL_optlstring(L, 3, "", &size);
|
const char *part;
|
||||||
|
int err = IO_DONE;
|
||||||
|
int top = lua_gettop(L);
|
||||||
|
if (top < 3) {
|
||||||
|
lua_settop(L, 3);
|
||||||
|
top = 3;
|
||||||
|
}
|
||||||
|
part = luaL_optlstring(L, 3, "", &size);
|
||||||
#ifdef LUASOCKET_DEBUG
|
#ifdef LUASOCKET_DEBUG
|
||||||
p_timeout tm = timeout_markstart(buf->tm);
|
p_timeout tm = timeout_markstart(buf->tm);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre
|
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -13,13 +13,16 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
OpenSSL version: OpenSSL 1.1.1
|
OpenSSL version: OpenSSL 3.0.0-beta2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static lsec_ssl_option_t ssl_options[] = {
|
static lsec_ssl_option_t ssl_options[] = {
|
||||||
#if defined(SSL_OP_ALL)
|
#if defined(SSL_OP_ALL)
|
||||||
{"all", SSL_OP_ALL},
|
{"all", SSL_OP_ALL},
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SSL_OP_ALLOW_CLIENT_RENEGOTIATION)
|
||||||
|
{"allow_client_renegotiation", SSL_OP_ALLOW_CLIENT_RENEGOTIATION},
|
||||||
|
#endif
|
||||||
#if defined(SSL_OP_ALLOW_NO_DHE_KEX)
|
#if defined(SSL_OP_ALLOW_NO_DHE_KEX)
|
||||||
{"allow_no_dhe_kex", SSL_OP_ALLOW_NO_DHE_KEX},
|
{"allow_no_dhe_kex", SSL_OP_ALLOW_NO_DHE_KEX},
|
||||||
#endif
|
#endif
|
||||||
@ -32,21 +35,33 @@ static lsec_ssl_option_t ssl_options[] = {
|
|||||||
#if defined(SSL_OP_CISCO_ANYCONNECT)
|
#if defined(SSL_OP_CISCO_ANYCONNECT)
|
||||||
{"cisco_anyconnect", SSL_OP_CISCO_ANYCONNECT},
|
{"cisco_anyconnect", SSL_OP_CISCO_ANYCONNECT},
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SSL_OP_CLEANSE_PLAINTEXT)
|
||||||
|
{"cleanse_plaintext", SSL_OP_CLEANSE_PLAINTEXT},
|
||||||
|
#endif
|
||||||
#if defined(SSL_OP_COOKIE_EXCHANGE)
|
#if defined(SSL_OP_COOKIE_EXCHANGE)
|
||||||
{"cookie_exchange", SSL_OP_COOKIE_EXCHANGE},
|
{"cookie_exchange", SSL_OP_COOKIE_EXCHANGE},
|
||||||
#endif
|
#endif
|
||||||
#if defined(SSL_OP_CRYPTOPRO_TLSEXT_BUG)
|
#if defined(SSL_OP_CRYPTOPRO_TLSEXT_BUG)
|
||||||
{"cryptopro_tlsext_bug", SSL_OP_CRYPTOPRO_TLSEXT_BUG},
|
{"cryptopro_tlsext_bug", SSL_OP_CRYPTOPRO_TLSEXT_BUG},
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SSL_OP_DISABLE_TLSEXT_CA_NAMES)
|
||||||
|
{"disable_tlsext_ca_names", SSL_OP_DISABLE_TLSEXT_CA_NAMES},
|
||||||
|
#endif
|
||||||
#if defined(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)
|
#if defined(SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)
|
||||||
{"dont_insert_empty_fragments", SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS},
|
{"dont_insert_empty_fragments", SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS},
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SSL_OP_ENABLE_KTLS)
|
||||||
|
{"enable_ktls", SSL_OP_ENABLE_KTLS},
|
||||||
|
#endif
|
||||||
#if defined(SSL_OP_ENABLE_MIDDLEBOX_COMPAT)
|
#if defined(SSL_OP_ENABLE_MIDDLEBOX_COMPAT)
|
||||||
{"enable_middlebox_compat", SSL_OP_ENABLE_MIDDLEBOX_COMPAT},
|
{"enable_middlebox_compat", SSL_OP_ENABLE_MIDDLEBOX_COMPAT},
|
||||||
#endif
|
#endif
|
||||||
#if defined(SSL_OP_EPHEMERAL_RSA)
|
#if defined(SSL_OP_EPHEMERAL_RSA)
|
||||||
{"ephemeral_rsa", SSL_OP_EPHEMERAL_RSA},
|
{"ephemeral_rsa", SSL_OP_EPHEMERAL_RSA},
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SSL_OP_IGNORE_UNEXPECTED_EOF)
|
||||||
|
{"ignore_unexpected_eof", SSL_OP_IGNORE_UNEXPECTED_EOF},
|
||||||
|
#endif
|
||||||
#if defined(SSL_OP_LEGACY_SERVER_CONNECT)
|
#if defined(SSL_OP_LEGACY_SERVER_CONNECT)
|
||||||
{"legacy_server_connect", SSL_OP_LEGACY_SERVER_CONNECT},
|
{"legacy_server_connect", SSL_OP_LEGACY_SERVER_CONNECT},
|
||||||
#endif
|
#endif
|
||||||
@ -89,6 +104,9 @@ static lsec_ssl_option_t ssl_options[] = {
|
|||||||
#if defined(SSL_OP_NO_ENCRYPT_THEN_MAC)
|
#if defined(SSL_OP_NO_ENCRYPT_THEN_MAC)
|
||||||
{"no_encrypt_then_mac", SSL_OP_NO_ENCRYPT_THEN_MAC},
|
{"no_encrypt_then_mac", SSL_OP_NO_ENCRYPT_THEN_MAC},
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SSL_OP_NO_EXTENDED_MASTER_SECRET)
|
||||||
|
{"no_extended_master_secret", SSL_OP_NO_EXTENDED_MASTER_SECRET},
|
||||||
|
#endif
|
||||||
#if defined(SSL_OP_NO_QUERY_MTU)
|
#if defined(SSL_OP_NO_QUERY_MTU)
|
||||||
{"no_query_mtu", SSL_OP_NO_QUERY_MTU},
|
{"no_query_mtu", SSL_OP_NO_QUERY_MTU},
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#define LSEC_OPTIONS_H
|
#define LSEC_OPTIONS_H
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre
|
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ local function usage()
|
|||||||
print(" lua options.lua -g /path/to/ssl.h [version] > options.c")
|
print(" lua options.lua -g /path/to/ssl.h [version] > options.c")
|
||||||
print("* Examples:")
|
print("* Examples:")
|
||||||
print(" lua options.lua -g /usr/include/openssl/ssl.h > options.c\n")
|
print(" lua options.lua -g /usr/include/openssl/ssl.h > options.c\n")
|
||||||
print(" lua options.lua -g /usr/include/openssl/ssl.h \"OpenSSL 1.0.1 14\" > options.c\n")
|
print(" lua options.lua -g /usr/include/openssl/ssl.h \"OpenSSL 1.1.1f\" > options.c\n")
|
||||||
|
|
||||||
print("* List options of your system:")
|
print("* List options of your system:")
|
||||||
print(" lua options.lua -l /path/to/ssl.h\n")
|
print(" lua options.lua -l /path/to/ssl.h\n")
|
||||||
@ -18,9 +18,9 @@ end
|
|||||||
local function generate(options, version)
|
local function generate(options, version)
|
||||||
print([[
|
print([[
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre
|
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -60,11 +60,14 @@ local function loadoptions(file)
|
|||||||
local options = {}
|
local options = {}
|
||||||
local f = assert(io.open(file, "r"))
|
local f = assert(io.open(file, "r"))
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
local op = string.match(line, "define%s+(SSL_OP_%S+)")
|
local op = string.match(line, "define%s+(SSL_OP_BIT%()")
|
||||||
|
if not op then
|
||||||
|
op = string.match(line, "define%s+(SSL_OP_%S+)")
|
||||||
if op then
|
if op then
|
||||||
table.insert(options, op)
|
table.insert(options, op)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
table.sort(options, function(a,b) return a<b end)
|
table.sort(options, function(a,b) return a<b end)
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
15
src/ssl.c
15
src/ssl.c
@ -1,9 +1,9 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2021 Kim Alvefur, Paul Aurich, Tobias Markmann,
|
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann,
|
||||||
* Matthew Wild.
|
* Matthew Wild.
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre.
|
* Copyright (C) 2006-2022 Bruno Silvestre.
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -48,6 +48,11 @@ static int lsec_socket_error()
|
|||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
return WSAGetLastError();
|
return WSAGetLastError();
|
||||||
#else
|
#else
|
||||||
|
#if defined(LSEC_OPENSSL_1_1_1)
|
||||||
|
// Bug in OpenSSL 1.1.1
|
||||||
|
if (errno == 0)
|
||||||
|
return LSEC_IO_SSL;
|
||||||
|
#endif
|
||||||
return errno;
|
return errno;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -742,6 +747,8 @@ static int sni_cb(SSL *ssl, int *ad, void *arg)
|
|||||||
lua_pop(L, 4);
|
lua_pop(L, 4);
|
||||||
/* Found, use this context */
|
/* Found, use this context */
|
||||||
if (newctx) {
|
if (newctx) {
|
||||||
|
p_context pctx = (p_context)SSL_CTX_get_app_data(newctx);
|
||||||
|
pctx->L = L;
|
||||||
SSL_set_SSL_CTX(ssl, newctx);
|
SSL_set_SSL_CTX(ssl, newctx);
|
||||||
return SSL_TLSEXT_ERR_OK;
|
return SSL_TLSEXT_ERR_OK;
|
||||||
}
|
}
|
||||||
@ -819,7 +826,7 @@ static int meth_getalpn(lua_State *L)
|
|||||||
|
|
||||||
static int meth_copyright(lua_State *L)
|
static int meth_copyright(lua_State *L)
|
||||||
{
|
{
|
||||||
lua_pushstring(L, "LuaSec 1.0 - Copyright (C) 2006-2021 Bruno Silvestre, UFG"
|
lua_pushstring(L, "LuaSec 1.1.0 - Copyright (C) 2006-2022 Bruno Silvestre, UFG"
|
||||||
#if defined(WITH_LUASOCKET)
|
#if defined(WITH_LUASOCKET)
|
||||||
"\nLuaSocket 3.0-RC1 - Copyright (C) 2004-2013 Diego Nehab"
|
"\nLuaSocket 3.0-RC1 - Copyright (C) 2004-2013 Diego Nehab"
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#define LSEC_SSL_H
|
#define LSEC_SSL_H
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre
|
* Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
10
src/ssl.lua
10
src/ssl.lua
@ -1,7 +1,7 @@
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
-- LuaSec 1.0
|
-- LuaSec 1.1.0
|
||||||
--
|
--
|
||||||
-- Copyright (C) 2006-2021 Bruno Silvestre
|
-- Copyright (C) 2006-2022 Bruno Silvestre
|
||||||
--
|
--
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -202,8 +202,12 @@ local function newcontext(cfg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if config.capabilities.dane and cfg.dane then
|
if config.capabilities.dane and cfg.dane then
|
||||||
|
if type(cfg.dane) == "table" then
|
||||||
|
context.setdane(ctx, unpack(cfg.dane))
|
||||||
|
else
|
||||||
context.setdane(ctx)
|
context.setdane(ctx)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
end
|
end
|
||||||
@ -271,7 +275,7 @@ core.setmethod("info", info)
|
|||||||
--
|
--
|
||||||
|
|
||||||
local _M = {
|
local _M = {
|
||||||
_VERSION = "1.0",
|
_VERSION = "1.1.0",
|
||||||
_COPYRIGHT = core.copyright(),
|
_COPYRIGHT = core.copyright(),
|
||||||
config = config,
|
config = config,
|
||||||
loadcertificate = x509.load,
|
loadcertificate = x509.load,
|
||||||
|
15
src/x509.c
15
src/x509.c
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2021 Kim Alvefur, Paul Aurich, Tobias Markmann
|
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann
|
||||||
* Matthew Wild, Bruno Silvestre.
|
* Matthew Wild, Bruno Silvestre.
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
@ -485,10 +485,13 @@ static int meth_digest(lua_State* L)
|
|||||||
*/
|
*/
|
||||||
static int meth_valid_at(lua_State* L)
|
static int meth_valid_at(lua_State* L)
|
||||||
{
|
{
|
||||||
|
int nb, na;
|
||||||
X509* cert = lsec_checkx509(L, 1);
|
X509* cert = lsec_checkx509(L, 1);
|
||||||
time_t time = luaL_checkinteger(L, 2);
|
time_t time = luaL_checkinteger(L, 2);
|
||||||
lua_pushboolean(L, (X509_cmp_time(X509_get0_notAfter(cert), &time) >= 0
|
nb = X509_cmp_time(X509_get0_notBefore(cert), &time);
|
||||||
&& X509_cmp_time(X509_get0_notBefore(cert), &time) <= 0));
|
time -= 1;
|
||||||
|
na = X509_cmp_time(X509_get0_notAfter(cert), &time);
|
||||||
|
lua_pushboolean(L, nb == -1 && na == 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,7 +658,7 @@ static int meth_set_encode(lua_State* L)
|
|||||||
/**
|
/**
|
||||||
* Get signature name.
|
* Get signature name.
|
||||||
*/
|
*/
|
||||||
static int meth_get_sinagure_name(lua_State* L)
|
static int meth_get_signature_name(lua_State* L)
|
||||||
{
|
{
|
||||||
p_x509 px = lsec_checkp_x509(L, 1);
|
p_x509 px = lsec_checkp_x509(L, 1);
|
||||||
int nid = X509_get_signature_nid(px->cert);
|
int nid = X509_get_signature_nid(px->cert);
|
||||||
@ -695,7 +698,7 @@ static luaL_Reg methods[] = {
|
|||||||
{"digest", meth_digest},
|
{"digest", meth_digest},
|
||||||
{"setencode", meth_set_encode},
|
{"setencode", meth_set_encode},
|
||||||
{"extensions", meth_extensions},
|
{"extensions", meth_extensions},
|
||||||
{"getsignaturename", meth_get_sinagure_name},
|
{"getsignaturename", meth_get_signature_name},
|
||||||
{"issuer", meth_issuer},
|
{"issuer", meth_issuer},
|
||||||
{"notbefore", meth_notbefore},
|
{"notbefore", meth_notbefore},
|
||||||
{"notafter", meth_notafter},
|
{"notafter", meth_notafter},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0
|
* LuaSec 1.1.0
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2021 Kim Alvefur, Paul Aurich, Tobias Markmann
|
* Copyright (C) 2014-2022 Kim Alvefur, Paul Aurich, Tobias Markmann
|
||||||
* Matthew Wild, Bruno Silvestre.
|
* Matthew Wild, Bruno Silvestre.
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
|
Reference in New Issue
Block a user