Software /
code /
prosody
Comparison
core/certmanager.lua @ 8259:db063671b73e
certmanager: Add debug logging (thanks av6)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 23 Sep 2017 17:13:29 +0100 |
parent | 8159:3850993a9bda |
child | 8274:3798955049e3 |
comparison
equal
deleted
inserted
replaced
8258:503f424d4f07 | 8259:db063671b73e |
---|---|
56 local crt_try = { "", "/%s.crt", "/%s/fullchain.pem", "/%s.pem", }; | 56 local crt_try = { "", "/%s.crt", "/%s/fullchain.pem", "/%s.pem", }; |
57 local key_try = { "", "/%s.key", "/%s/privkey.pem", "/%s.pem", }; | 57 local key_try = { "", "/%s.key", "/%s/privkey.pem", "/%s.pem", }; |
58 | 58 |
59 local function find_cert(user_certs, name) | 59 local function find_cert(user_certs, name) |
60 local certs = resolve_path(config_path, user_certs or global_certificates); | 60 local certs = resolve_path(config_path, user_certs or global_certificates); |
61 log("debug", "Searching %s for a key and certificate for %s...", certs, name); | |
61 for i = 1, #crt_try do | 62 for i = 1, #crt_try do |
62 local crt_path = certs .. crt_try[i]:format(name); | 63 local crt_path = certs .. crt_try[i]:format(name); |
63 local key_path = certs .. key_try[i]:format(name); | 64 local key_path = certs .. key_try[i]:format(name); |
64 | 65 |
65 if stat(crt_path, "mode") == "file" then | 66 if stat(crt_path, "mode") == "file" then |
66 if key_path:sub(-4) == ".crt" then | 67 if key_path:sub(-4) == ".crt" then |
67 key_path = key_path:sub(1, -4) .. "key"; | 68 key_path = key_path:sub(1, -4) .. "key"; |
68 if stat(key_path, "mode") == "file" then | 69 if stat(key_path, "mode") == "file" then |
70 log("debug", "Selecting certificate %s with key %s for %s", crt_path, key_path, name); | |
69 return { certificate = crt_path, key = key_path }; | 71 return { certificate = crt_path, key = key_path }; |
70 end | 72 end |
71 elseif stat(key_path, "mode") == "file" then | 73 elseif stat(key_path, "mode") == "file" then |
74 log("debug", "Selecting certificate %s with key %s for %s", crt_path, key_path, name); | |
72 return { certificate = crt_path, key = key_path }; | 75 return { certificate = crt_path, key = key_path }; |
73 end | 76 end |
74 end | 77 end |
75 end | 78 end |
79 log("debug", "No certificate/key found for %s", name); | |
76 end | 80 end |
77 | 81 |
78 local function find_host_cert(host) | 82 local function find_host_cert(host) |
79 if not host then return nil; end | 83 if not host then return nil; end |
80 return find_cert(configmanager.get(host, "certificate"), host) or find_host_cert(host:match("%.(.+)$")); | 84 return find_cert(configmanager.get(host, "certificate"), host) or find_host_cert(host:match("%.(.+)$")); |