Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x509.*) fix set_extension will fail when a extension with same NID #75

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/resty/openssl/x509/crl.lua
Original file line number Diff line number Diff line change
@@ -421,9 +421,7 @@ function _M:set_extension(extension, last_pos)

local nid = extension:get_object().nid
local pos = C.X509_CRL_get_ext_by_NID(self.ctx, nid, last_pos)
if pos == -1 then
return nil
end
-- pos may be -1, which means not found, it's fine, we will add new one instead of replace

local removed = X509_CRL_delete_ext(self.ctx, pos)
C.X509_EXTENSION_free(removed)
4 changes: 1 addition & 3 deletions lib/resty/openssl/x509/init.lua
Original file line number Diff line number Diff line change
@@ -495,9 +495,7 @@ function _M:set_extension(extension, last_pos)

local nid = extension:get_object().nid
local pos = C.X509_get_ext_by_NID(self.ctx, nid, last_pos)
if pos == -1 then
return nil
end
-- pos may be -1, which means not found, it's fine, we will add new one instead of replace

local removed = X509_delete_ext(self.ctx, pos)
C.X509_EXTENSION_free(removed)
4 changes: 1 addition & 3 deletions scripts/templates/x509_functions.j2
Original file line number Diff line number Diff line change
@@ -112,9 +112,7 @@ function _M:set_extension(extension, last_pos)

local nid = extension:get_object().nid
local pos = C.{{ module.type }}_get_ext_by_NID(self.ctx, nid, last_pos)
if pos == -1 then
return nil
end
-- pos may be -1, which means not found, it's fine, we will add new one instead of replace

local removed = {{ module.type }}_delete_ext(self.ctx, pos)
C.X509_EXTENSION_free(removed)