mirror of
https://github.com/matrix-construct/construct
synced 2025-02-17 01:00:10 +01:00
modules/console: Add certificate diagnostic cmd.
This commit is contained in:
parent
295794ec42
commit
86a946ab89
1 changed files with 72 additions and 15 deletions
|
@ -4753,6 +4753,78 @@ console_cmd__resource(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
bool
|
||||
console_cmd__crt(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"listener|path"
|
||||
}};
|
||||
|
||||
string_view filename;
|
||||
const string_view &targ
|
||||
{
|
||||
param.at("listener|path")
|
||||
};
|
||||
|
||||
static mods::import<std::list<net::listener>> listeners
|
||||
{
|
||||
"s_listen", "listeners"
|
||||
};
|
||||
|
||||
const auto &list{*listeners};
|
||||
for(const auto &listener : list)
|
||||
{
|
||||
if(listener.name() != targ)
|
||||
continue;
|
||||
|
||||
const json::object &config
|
||||
{
|
||||
listener
|
||||
};
|
||||
|
||||
filename = unquote(config.get("certificate_pem_path"));
|
||||
}
|
||||
|
||||
if(!filename)
|
||||
{
|
||||
filename = targ;
|
||||
return true;
|
||||
}
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
32_KiB
|
||||
};
|
||||
|
||||
const std::string certfile
|
||||
{
|
||||
fs::read(filename)
|
||||
};
|
||||
|
||||
out << openssl::printX509(buf, certfile) << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__crt__create(opt &out, const string_view &line)
|
||||
{
|
||||
using prototype = void (const m::event &);
|
||||
static mods::import<prototype> create_my_key
|
||||
{
|
||||
"s_keys", "create_my_key"
|
||||
};
|
||||
|
||||
create_my_key({});
|
||||
|
||||
out << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// key
|
||||
//
|
||||
|
@ -4812,21 +4884,6 @@ console_cmd__key__get(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__key__crt__sign(opt &out, const string_view &line)
|
||||
{
|
||||
using prototype = void (const m::event &);
|
||||
static mods::import<prototype> create_my_key
|
||||
{
|
||||
"s_keys", "create_my_key"
|
||||
};
|
||||
|
||||
create_my_key({});
|
||||
|
||||
out << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// stage
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue