|
|
|
|
94
|
local wait, done = async.waiter();
|
94
|
local wait, done = async.waiter();
|
95
|
local function cb(content_, code_, response_, request_)
|
95
|
local function cb(content_, code_, response_, request_)
|
96
|
content, code = content_, code_;
|
96
|
content, code = content_, code_;
|
|
|
97
|
+ if code == 200 or code == 204 then
|
|
|
98
|
+ cache:set(keyId, content);
|
|
|
99
|
+ end
|
97
|
done();
|
100
|
done();
|
98
|
end
|
101
|
end
|
99
|
module:log("debug", "Fetching public key from: "..asapKeyServer..keyId);
|
102
|
module:log("debug", "Fetching public key from: "..asapKeyServer..keyId);
|
100
|
|
103
|
|
101
|
- -- We hash the key ID to work around some legacy behavior in the original
|
|
|
102
|
- -- deployment and make deployment easier. It also helps prevent directory
|
|
|
|
|
104
|
+ -- We hash the key ID to work around some legacy behavior and make
|
|
|
105
|
+ -- deployment easier. It also helps prevent directory
|
103
|
-- traversal attacks (although path cleaning could have done this too).
|
106
|
-- traversal attacks (although path cleaning could have done this too).
|
104
|
local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
|
107
|
local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
|
105
|
headers = http_headers or {},
|
108
|
headers = http_headers or {},
|