Plugin Message Continuation
| 38 | |
| 39 | // Plugin Message Continuation |
| 40 | int |
| 41 | CB_cert_update(TSCont, TSEvent, void *edata) |
| 42 | { |
| 43 | TSPluginMsg *msg = static_cast<TSPluginMsg *>(edata); |
| 44 | static constexpr std::string_view PLUGIN_PREFIX("cert_update."); |
| 45 | |
| 46 | std::string_view tag(msg->tag, strlen(msg->tag)); |
| 47 | const char *server_cert_path = nullptr; |
| 48 | const char *client_cert_path = nullptr; |
| 49 | if (tag.substr(0, PLUGIN_PREFIX.size()) == PLUGIN_PREFIX) { |
| 50 | tag.remove_prefix(PLUGIN_PREFIX.size()); |
| 51 | if (tag == "server") { |
| 52 | server_cert_path = static_cast<const char *>(msg->data); |
| 53 | Dbg(dbg_ctl, "Received Msg to update server cert with %s", server_cert_path); |
| 54 | } else if (tag == "client") { |
| 55 | client_cert_path = static_cast<const char *>(msg->data); |
| 56 | Dbg(dbg_ctl, "Received Msg to update client cert with %s", client_cert_path); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if (server_cert_path) { |
| 61 | if (TS_SUCCESS == TSSslServerCertUpdate(server_cert_path, nullptr)) { |
| 62 | Dbg(dbg_ctl, "Successfully updated server cert with %s", server_cert_path); |
| 63 | } else { |
| 64 | Dbg(dbg_ctl, "Failed to update server cert with %s", server_cert_path); |
| 65 | } |
| 66 | } |
| 67 | if (client_cert_path) { |
| 68 | if (TS_SUCCESS == TSSslClientCertUpdate(client_cert_path, nullptr)) { |
| 69 | Dbg(dbg_ctl, "Successfully updated client cert with %s", client_cert_path); |
| 70 | } else { |
| 71 | Dbg(dbg_ctl, "Failed to update client cert with %s", client_cert_path); |
| 72 | } |
| 73 | } |
| 74 | return TS_SUCCESS; |
| 75 | } |
| 76 | |
| 77 | void |
| 78 | TSPluginInit(int /* argc ATS_UNUSED */, const char ** /* argv ATS_UNUSED */) |
nothing calls this directly
no test coverage detected