| 85 | } |
| 86 | |
| 87 | std::string |
| 88 | SSLSecret::loadFile(const std::string &name) |
| 89 | { |
| 90 | Dbg(dbg_ctl_ssl_secret, "SSLSecret::loadFile(%s)", name.c_str()); |
| 91 | std::error_code error; |
| 92 | std::string const data = swoc::file::load(swoc::file::path(name), error); |
| 93 | if (error) { |
| 94 | Dbg(dbg_ctl_ssl_secret_err, "SSLSecret::loadFile(%s) failed error code=%d message=%s", name.c_str(), error.value(), |
| 95 | error.message().c_str()); |
| 96 | // Loading file failed |
| 97 | Dbg(dbg_ctl_ssl_secret, "Loading file: %s failed ", name.c_str()); |
| 98 | return std::string{}; |
| 99 | } |
| 100 | if (dbg_ctl_ssl_secret.on()) { |
| 101 | char hash_str[EVP_MAX_MD_SIZE * 2]; |
| 102 | unsigned int hash_len; |
| 103 | get_hash_str(data, hash_str, &hash_len); |
| 104 | DbgPrint(dbg_ctl_ssl_secret, "Secret hash: %.*s", hash_len, hash_str); |
| 105 | DbgPrint(dbg_ctl_ssl_secret, "Secret data: %.50s", data.c_str()); |
| 106 | } |
| 107 | if (SSLConfigParams::load_ssl_file_cb) { |
| 108 | SSLConfigParams::load_ssl_file_cb(name.c_str()); |
| 109 | } |
| 110 | return data; |
| 111 | } |
| 112 | |
| 113 | void |
| 114 | SSLSecret::setSecret(const std::string &name, std::string_view data) |