This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new f7a8898c1a Add sslheaders and remove extra cert_update plugin (#10519)
f7a8898c1a is described below
commit f7a8898c1a431dbd95e7a8f17314fe6ecb2de0f2
Author: Chris McFarlen <[email protected]>
AuthorDate: Tue Sep 26 15:07:04 2023 -0500
Add sslheaders and remove extra cert_update plugin (#10519)
---
example/plugins/c-api/CMakeLists.txt | 92 +++++++++++-----------
plugins/experimental/CMakeLists.txt | 1 +
.../experimental/{ => sslheaders}/CMakeLists.txt | 36 +++------
tests/tools/plugins/CMakeLists.txt | 2 -
tests/tools/plugins/Makefile.inc | 3 -
tests/tools/plugins/cert_update.cc | 91 ---------------------
6 files changed, 59 insertions(+), 166 deletions(-)
diff --git a/example/plugins/c-api/CMakeLists.txt
b/example/plugins/c-api/CMakeLists.txt
index cce968816f..9262c13bc1 100644
--- a/example/plugins/c-api/CMakeLists.txt
+++ b/example/plugins/c-api/CMakeLists.txt
@@ -18,49 +18,49 @@
include(add_atsplugin)
-add_atsplugin(example_cache_scan ./cache_scan/cache_scan.cc)
-add_atsplugin(example_lifecycle_plugin ./lifecycle_plugin/lifecycle_plugin.cc)
-add_atsplugin(example_request_buffer ./request_buffer/request_buffer.cc)
-add_atsplugin(example_secure_link ./secure_link/secure_link.cc)
-target_link_libraries(example_secure_link PRIVATE OpenSSL::SSL)
-add_atsplugin(example_remap ./remap/remap.cc)
-add_atsplugin(example_redirect_1 ./redirect_1/redirect_1.cc)
-add_atsplugin(example_query_remap ./query_remap/query_remap.cc)
-add_atsplugin(example_thread_pool ./thread_pool/psi.cc ./thread_pool/thread.cc)
-add_atsplugin(example_bnull_transform ./bnull_transform/bnull_transform.cc)
-add_atsplugin(example_replace_header ./replace_header/replace_header.cc)
-add_atsplugin(example_ssl_sni ./ssl_sni/ssl_sni.cc)
-target_link_libraries(example_ssl_sni PRIVATE OpenSSL::SSL)
-add_atsplugin(example_passthru ./passthru/passthru.cc)
-add_atsplugin(example_response_header_1
./response_header_1/response_header_1.cc)
-add_atsplugin(example_denylist_1 ./denylist_1/denylist_1.cc)
-add_atsplugin(example_denylist_0 ./denylist_0/denylist_0.cc)
-add_atsplugin(example_server_push ./server_push/server_push.cc)
-add_atsplugin(example_basic_auth ./basic_auth/basic_auth.cc)
-add_atsplugin(example_verify_cert ./verify_cert/verify_cert.cc)
-target_link_libraries(example_verify_cert PRIVATE OpenSSL::SSL)
-add_atsplugin(example_intercept ./intercept/intercept.cc)
-add_atsplugin(example_null_transform ./null_transform/null_transform.cc)
-add_atsplugin(example_ssl_sni_allowlist
./ssl_sni_allowlist/ssl_sni_allowlist.cc)
-target_link_libraries(example_ssl_sni_allowlist PRIVATE OpenSSL::SSL)
-add_atsplugin(example_protocol ./protocol/Protocol.cc ./protocol/TxnSM.cc)
-add_atsplugin(example_file_1 ./file_1/file_1.cc)
-add_atsplugin(example_output_header ./output_header/output_header.cc)
-add_atsplugin(example_session_hooks ./session_hooks/session_hooks.cc)
-add_atsplugin(example_add_header ./add_header/add_header.cc)
-add_atsplugin(example_version ./version/version.cc)
-add_atsplugin(example_ssl_preaccept ./ssl_preaccept/ssl_preaccept.cc)
-add_atsplugin(example_txn_data_sink ./txn_data_sink/txn_data_sink.cc)
-add_atsplugin(example_remap_header_add ./remap_header_add/remap_header_add.cc)
-add_atsplugin(example_disable_http2 ./disable_http2/disable_http2.cc)
-target_link_libraries(example_disable_http2 PRIVATE OpenSSL::SSL)
-add_atsplugin(example_server_transform ./server_transform/server_transform.cc)
-add_atsplugin(example_append_transform ./append_transform/append_transform.cc)
-add_atsplugin(example_thread_1 ./thread_1/thread_1.cc)
-add_atsplugin(example_vconn_args ./vconn_args/vconn_args.cc)
-add_atsplugin(example_cert_update ./cert_update/cert_update.cc)
-add_atsplugin(example_hello ./hello/hello.cc)
-add_atsplugin(example_statistic ./statistic/statistic.cc)
-add_atsplugin(example_protocol_stack ./protocol_stack/protocol_stack.cc)
-add_atsplugin(example_client_context_dump
./client_context_dump/client_context_dump.cc)
-target_link_libraries(example_client_context_dump PRIVATE OpenSSL::SSL)
+add_atsplugin(cache_scan ./cache_scan/cache_scan.cc)
+add_atsplugin(lifecycle_plugin ./lifecycle_plugin/lifecycle_plugin.cc)
+add_atsplugin(request_buffer ./request_buffer/request_buffer.cc)
+add_atsplugin(secure_link ./secure_link/secure_link.cc)
+target_link_libraries(secure_link PRIVATE OpenSSL::SSL)
+add_atsplugin(remap ./remap/remap.cc)
+add_atsplugin(redirect_1 ./redirect_1/redirect_1.cc)
+add_atsplugin(query_remap ./query_remap/query_remap.cc)
+add_atsplugin(thread_pool ./thread_pool/psi.cc ./thread_pool/thread.cc)
+add_atsplugin(bnull_transform ./bnull_transform/bnull_transform.cc)
+add_atsplugin(replace_header ./replace_header/replace_header.cc)
+add_atsplugin(ssl_sni ./ssl_sni/ssl_sni.cc)
+target_link_libraries(ssl_sni PRIVATE OpenSSL::SSL)
+add_atsplugin(passthru ./passthru/passthru.cc)
+add_atsplugin(response_header_1 ./response_header_1/response_header_1.cc)
+add_atsplugin(denylist_1 ./denylist_1/denylist_1.cc)
+add_atsplugin(denylist_0 ./denylist_0/denylist_0.cc)
+add_atsplugin(server_push ./server_push/server_push.cc)
+add_atsplugin(basic_auth ./basic_auth/basic_auth.cc)
+add_atsplugin(verify_cert ./verify_cert/verify_cert.cc)
+target_link_libraries(verify_cert PRIVATE OpenSSL::SSL)
+add_atsplugin(intercept ./intercept/intercept.cc)
+add_atsplugin(null_transform ./null_transform/null_transform.cc)
+add_atsplugin(ssl_sni_allowlist ./ssl_sni_allowlist/ssl_sni_allowlist.cc)
+target_link_libraries(ssl_sni_allowlist PRIVATE OpenSSL::SSL)
+add_atsplugin(protocol ./protocol/Protocol.cc ./protocol/TxnSM.cc)
+add_atsplugin(file_1 ./file_1/file_1.cc)
+add_atsplugin(output_header ./output_header/output_header.cc)
+add_atsplugin(session_hooks ./session_hooks/session_hooks.cc)
+add_atsplugin(add_header ./add_header/add_header.cc)
+add_atsplugin(version ./version/version.cc)
+add_atsplugin(ssl_preaccept ./ssl_preaccept/ssl_preaccept.cc)
+add_atsplugin(txn_data_sink ./txn_data_sink/txn_data_sink.cc)
+add_atsplugin(remap_header_add ./remap_header_add/remap_header_add.cc)
+add_atsplugin(disable_http2 ./disable_http2/disable_http2.cc)
+target_link_libraries(disable_http2 PRIVATE OpenSSL::SSL)
+add_atsplugin(server_transform ./server_transform/server_transform.cc)
+add_atsplugin(append_transform ./append_transform/append_transform.cc)
+add_atsplugin(thread_1 ./thread_1/thread_1.cc)
+add_atsplugin(vconn_args ./vconn_args/vconn_args.cc)
+add_atsplugin(cert_update ./cert_update/cert_update.cc)
+add_atsplugin(hello ./hello/hello.cc)
+add_atsplugin(statistic ./statistic/statistic.cc)
+add_atsplugin(protocol_stack ./protocol_stack/protocol_stack.cc)
+add_atsplugin(client_context_dump ./client_context_dump/client_context_dump.cc)
+target_link_libraries(client_context_dump PRIVATE OpenSSL::SSL)
diff --git a/plugins/experimental/CMakeLists.txt
b/plugins/experimental/CMakeLists.txt
index d25994d1a1..54f88d73d1 100644
--- a/plugins/experimental/CMakeLists.txt
+++ b/plugins/experimental/CMakeLists.txt
@@ -34,6 +34,7 @@ add_subdirectory(money_trace)
add_subdirectory(mp4)
add_subdirectory(rate_limit)
add_subdirectory(redo_cache_lookup)
+add_subdirectory(sslheaders)
add_subdirectory(stek_share)
add_subdirectory(stream_editor)
add_subdirectory(system_stats)
diff --git a/plugins/experimental/CMakeLists.txt
b/plugins/experimental/sslheaders/CMakeLists.txt
similarity index 54%
copy from plugins/experimental/CMakeLists.txt
copy to plugins/experimental/sslheaders/CMakeLists.txt
index d25994d1a1..24e3419c00 100644
--- a/plugins/experimental/CMakeLists.txt
+++ b/plugins/experimental/sslheaders/CMakeLists.txt
@@ -15,27 +15,15 @@
#
#######################
-add_subdirectory(access_control)
-add_subdirectory(cache_fill)
-add_subdirectory(cert_reporting_tool)
-add_subdirectory(cookie_remap)
-add_subdirectory(custom_redirect)
-add_subdirectory(fq_pacing)
-add_subdirectory(geoip_acl)
-add_subdirectory(header_freq)
-add_subdirectory(hook-trace)
-add_subdirectory(http_stats)
-add_subdirectory(icap)
-add_subdirectory(inliner)
-add_subdirectory(maxmind_acl)
-add_subdirectory(memcache)
-add_subdirectory(memory_profile)
-add_subdirectory(money_trace)
-add_subdirectory(mp4)
-add_subdirectory(rate_limit)
-add_subdirectory(redo_cache_lookup)
-add_subdirectory(stek_share)
-add_subdirectory(stream_editor)
-add_subdirectory(system_stats)
-add_subdirectory(tls_bridge)
-add_subdirectory(url_sig)
+add_library(sslhdr STATIC expand.cc util.cc)
+target_link_libraries(sslhdr PRIVATE OpenSSL::SSL)
+set_target_properties(sslhdr PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
+
+if(BUILD_TESTING)
+ add_executable(test_sslhdr unit_tests/unit_test_main.cc
unit_tests/test_sslheaders.cc)
+ target_link_libraries(test_sslhdr PRIVATE sslhdr catch2::catch2)
+endif()
+
+
+add_atsplugin(sslheaders sslheaders.cc)
+target_link_libraries(sslheaders PRIVATE sslhdr)
diff --git a/tests/tools/plugins/CMakeLists.txt
b/tests/tools/plugins/CMakeLists.txt
index 407a54adfb..fc076cc534 100644
--- a/tests/tools/plugins/CMakeLists.txt
+++ b/tests/tools/plugins/CMakeLists.txt
@@ -15,7 +15,6 @@
#
#######################
-add_autest_plugin(cert_update cert_update.cc)
add_autest_plugin(conf_remap_stripped conf_remap_stripped.cc)
add_autest_plugin(continuations_verify continuations_verify.cc)
add_autest_plugin(cont_schedule cont_schedule.cc)
@@ -41,7 +40,6 @@ add_autest_plugin(user_args user_args.cc)
add_autest_plugin(async_engine async_engine.c)
add_autest_plugin(hook_tunnel_plugin hook_tunnel_plugin.c)
-target_link_libraries(cert_update PRIVATE OpenSSL::SSL)
target_link_libraries(continuations_verify PRIVATE OpenSSL::SSL)
target_link_libraries(ssl_client_verify_test PRIVATE OpenSSL::SSL)
target_link_libraries(ssl_hook_test PRIVATE OpenSSL::SSL)
diff --git a/tests/tools/plugins/Makefile.inc b/tests/tools/plugins/Makefile.inc
index 863eb3ecc9..ae7d6ef8e5 100644
--- a/tests/tools/plugins/Makefile.inc
+++ b/tests/tools/plugins/Makefile.inc
@@ -14,9 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-noinst_LTLIBRARIES += tools/plugins/cert_update.la
-tools_plugins_cert_update_la_SOURCES = tools/plugins/cert_update.cc
-
noinst_LTLIBRARIES += tools/plugins/conf_remap_stripped.la
tools_plugins_conf_remap_stripped_la_SOURCES =
tools/plugins/conf_remap_stripped.cc
diff --git a/tests/tools/plugins/cert_update.cc
b/tests/tools/plugins/cert_update.cc
deleted file mode 100644
index 338815b0fa..0000000000
--- a/tests/tools/plugins/cert_update.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file
-
- an example cert update plugin
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#include <cstdio>
-#include <cstring>
-#include <string>
-#include <string_view>
-
-#include "ts/ts.h"
-#include "swoc/TextView.h"
-
-#define PLUGIN_NAME "cert_update"
-
-namespace
-{
-DbgCtl dbg_ctl{PLUGIN_NAME};
-}
-
-// Plugin Message Continuation
-int
-CB_cert_update(TSCont, TSEvent, void *edata)
-{
- TSPluginMsg *msg = static_cast<TSPluginMsg *>(edata);
- static constexpr std::string_view PLUGIN_PREFIX("cert_update.");
-
- std::string_view tag(msg->tag, strlen(msg->tag));
- const char *server_cert_path = nullptr;
- const char *client_cert_path = nullptr;
- if (tag.substr(0, PLUGIN_PREFIX.size()) == PLUGIN_PREFIX) {
- tag.remove_prefix(PLUGIN_PREFIX.size());
- if (tag == "server") {
- server_cert_path = static_cast<const char *>(msg->data);
- Dbg(dbg_ctl, "Received Msg to update server cert with %s",
server_cert_path);
- } else if (tag == "client") {
- client_cert_path = static_cast<const char *>(msg->data);
- Dbg(dbg_ctl, "Received Msg to update client cert with %s",
client_cert_path);
- }
- }
-
- if (server_cert_path) {
- if (TS_SUCCESS == TSSslServerCertUpdate(server_cert_path, nullptr)) {
- Dbg(dbg_ctl, "Successfully updated server cert with %s",
server_cert_path);
- } else {
- Dbg(dbg_ctl, "Failed to update server cert with %s", server_cert_path);
- }
- }
- if (client_cert_path) {
- if (TS_SUCCESS == TSSslClientCertUpdate(client_cert_path, nullptr)) {
- Dbg(dbg_ctl, "Successfully updated client cert with %s",
client_cert_path);
- } else {
- Dbg(dbg_ctl, "Failed to update client cert with %s", client_cert_path);
- }
- }
- return TS_SUCCESS;
-}
-
-void
-TSPluginInit(int argc, const char *argv[])
-{
- TSPluginRegistrationInfo info;
-
- info.plugin_name = PLUGIN_NAME;
- info.vendor_name = "Apache Software Foundation";
- info.support_email = "[email protected]";
-
- if (TSPluginRegister(&info) != TS_SUCCESS) {
- TSError("[%s] Plugin registration failed", PLUGIN_NAME);
- }
- Dbg(dbg_ctl, "Initialized.");
- TSLifecycleHookAdd(TS_LIFECYCLE_MSG_HOOK, TSContCreate(CB_cert_update,
nullptr));
-}