|
@@ -3,11 +3,13 @@
|
3
|
3
|
|
4
|
4
|
local basexx = require "basexx";
|
5
|
5
|
local have_async, async = pcall(require, "util.async");
|
|
6
|
+local hex = require "util.hex";
|
6
|
7
|
local formdecode = require "util.http".formdecode;
|
7
|
8
|
local generate_uuid = require "util.uuid".generate;
|
8
|
9
|
local http = require "net.http";
|
9
|
10
|
local json = require "cjson";
|
10
|
11
|
local new_sasl = require "util.sasl".new;
|
|
12
|
+local path = require "util.paths";
|
11
|
13
|
local sasl = require "util.sasl";
|
12
|
14
|
local sha256 = require "util.hashes".sha256;
|
13
|
15
|
local timer = require "util.timer";
|
|
@@ -99,12 +101,13 @@ function get_public_key(keyId)
|
99
|
101
|
end
|
100
|
102
|
done();
|
101
|
103
|
end
|
102
|
|
- module:log("debug", "Fetching public key from: "..asapKeyServer..keyId);
|
|
104
|
+ local keyurl = path.join(asapKeyServer, hex.to(sha256(keyId))..'.pem');
|
|
105
|
+ module:log("debug", "Fetching public key from: "..keyurl);
|
103
|
106
|
|
104
|
107
|
-- We hash the key ID to work around some legacy behavior and make
|
105
|
108
|
-- deployment easier. It also helps prevent directory
|
106
|
109
|
-- traversal attacks (although path cleaning could have done this too).
|
107
|
|
- local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
|
|
110
|
+ local request = http.request(keyurl, {
|
108
|
111
|
headers = http_headers or {},
|
109
|
112
|
method = "GET"
|
110
|
113
|
}, cb);
|