-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: check decrypt key to prevent lua thread aborted #2815
Conversation
@starsz Your git commit message should be "semantic": https://github.com/zeke/semantic-pull-requests |
9e700e3
to
afacc0e
Compare
Because the title is started with "WIP". Now it's fixed. |
t/router/radixtree-sni.t
Outdated
local core = require("apisix.core") | ||
local t = require("lib.test_admin") | ||
|
||
local ssl_cert = t.read_file("t/certs/miss_head.crt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ssl creation will be failed if #2816 is solved. You have to solve this case that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or add a TODO comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TODO comment and I will solve this case in SSL certificate check
PR.
t/certs/miss_head.crt
Outdated
@@ -0,0 +1,25 @@ | |||
MIIEojCCAwqgAwIBAgIJAK253pMhgCkxMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to introduce yet another bad cert and key just for mimicking bad base64 decoded strings. Do it by literal strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
apisix/ssl/router/radixtree_sni.lua
Outdated
return decrypted | ||
local decoded_key = ngx_decode_base64(key) | ||
if not decoded_key then | ||
core.log.error("base64 decode ssl key failed. key[", key, "] ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to mention that we will skip the bad key in the error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
apisix/ssl/router/radixtree_sni.lua
Outdated
core.log.error("decrypt ssl key failed. key[", key, "] ") | ||
local decrypted = iv:decrypt(decoded_key) | ||
if not decrypted then | ||
core.log.error("decrypt ssl key failed. key[", key, "] ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
05378b3
to
56aa1d6
Compare
What this PR does / why we need it:
Hi, I found that the decrypt function in
aes.lua
will cause lua thread aborted if the key is nil.fix: #2791
Pre-submission checklist: