|
@@ -9,6 +9,7 @@ local http = require "net.http";
|
9
|
9
|
local json = require "cjson";
|
10
|
10
|
local new_sasl = require "util.sasl".new;
|
11
|
11
|
local sasl = require "util.sasl";
|
|
12
|
+local sha256 = require "util.hashes".sha256;
|
12
|
13
|
local timer = require "util.timer";
|
13
|
14
|
local token_util = module:require "token/util";
|
14
|
15
|
|
|
@@ -96,10 +97,15 @@ function get_public_key(keyId)
|
96
|
97
|
done();
|
97
|
98
|
end
|
98
|
99
|
module:log("debug", "Fetching public key from: "..asapKeyServer..keyId);
|
99
|
|
- local request = http.request(asapKeyServer..keyId, {
|
|
100
|
+
|
|
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
|
|
103
|
+ -- traversal attacks (although path cleaning could have done this too).
|
|
104
|
+ local request = http.request(asapKeyServer..sha256(keyId)..'.pem', {
|
100
|
105
|
headers = http_headers or {},
|
101
|
106
|
method = "GET"
|
102
|
107
|
}, cb);
|
|
108
|
+
|
103
|
109
|
-- TODO: Is the done() call racey? Can we cancel this if the request
|
104
|
110
|
-- succeedes?
|
105
|
111
|
local function cancel()
|