Skip to content

Commit 5af0f4b

Browse files
committed
fix(csr) count extension count in openssl 3.0
openssl/openssl@2039ac0 introduces a change that a empty stack instead of NULL will be returned in no extension is found. so we need to double check the number if it's not NULL.
1 parent 29d3637 commit 5af0f4b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.github/workflows/tests.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ jobs:
3939
openssl_opts: "fips --with-fipsdir=/home/runner/work/cache/ssl/fips"
4040
valgrind: "valgrind"
4141
# latest and one older version with alpha release
42-
# - nginx: "1.17.8"
43-
# openssl: "3.0.0-alpha11"
44-
# nginx_cc_opts: "-Wno-error"
45-
# - nginx: "1.19.3"
46-
# openssl: "3.0.0-alpha11"
47-
# nginx_cc_opts: "-Wno-error"
42+
- nginx: "1.17.8"
43+
openssl: "3.0.0-alpha11"
44+
nginx_cc_opts: "-Wno-error"
45+
- nginx: "1.19.3"
46+
openssl: "3.0.0-alpha11"
47+
nginx_cc_opts: "-Wno-error"
4848

4949
env:
5050
JOBS: 3

lib/resty/openssl/x509/csr.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require "resty.openssl.include.pem"
77
require "resty.openssl.include.x509v3"
88
require "resty.openssl.include.x509.csr"
99
require "resty.openssl.include.asn1"
10+
local stack_macro = require "resty.openssl.include.stack"
1011
local stack_lib = require "resty.openssl.stack"
1112
local pkey_lib = require "resty.openssl.pkey"
1213
local digest_lib = require("resty.openssl.digest")
@@ -18,6 +19,7 @@ local txtnid2nid = require("resty.openssl.objects").txtnid2nid
1819
local format_error = require("resty.openssl.err").format_error
1920
local OPENSSL_10 = require("resty.openssl.version").OPENSSL_10
2021
local OPENSSL_11_OR_LATER = require("resty.openssl.version").OPENSSL_11_OR_LATER
22+
local OPENSSL_30 = require("resty.openssl.version").OPENSSL_30
2123

2224
local accessors = {}
2325

@@ -206,8 +208,12 @@ end
206208
local function modify_extension(replace, ctx, nid, toset, crit)
207209
local extensions_ptr = stack_ptr_type()
208210
extensions_ptr[0] = C.X509_REQ_get_extensions(ctx)
209-
local need_cleanup = extensions_ptr[0] ~= nil
211+
local need_cleanup = extensions_ptr[0] ~= nil and
210212
-- extensions_ptr being nil is fine: it may just because there's no extension yet
213+
-- https://github.com/openssl/openssl/commit/2039ac07b401932fa30a05ade80b3626e189d78a
214+
-- introduces a change that a empty stack instead of NULL will be returned in no extension
215+
-- is found. so we need to double check the number if it's not NULL.
216+
stack_macro.OPENSSL_sk_num(extensions_ptr[0]) > 0
211217

212218
local flag
213219
if replace then

0 commit comments

Comments
 (0)