- Category
- Security - TLS policy configuration
Demonstrates:
- no_tls policy for plain-text connections
- tls_enabled policy with certificate configuration
- Compile-time TLS policy selection
- See also
- kcenon::network::policy::no_tls
-
kcenon::network::policy::tls_enabled
#include <iostream>
#include <string>
template <typename TlsPolicy>
{
std::cout << " " << label << ": TLS "
<< (TlsPolicy::enabled ? "enabled" : "disabled") << std::endl;
}
{
std::cout << "=== TLS Policy Example ===" << std::endl;
std::cout << "\n1. Compile-time policy inspection:" << std::endl;
std::cout << "\n2. TLS enabled configuration:" << std::endl;
tls_config.
cert_path =
"/etc/ssl/certs/server.crt";
tls_config.
key_path =
"/etc/ssl/private/server.key";
tls_config.
ca_path =
"/etc/ssl/certs/ca-bundle.crt";
std::cout <<
" Certificate: " << tls_config.
cert_path << std::endl;
std::cout <<
" Private key: " << tls_config.
key_path << std::endl;
std::cout <<
" CA bundle: " << tls_config.
ca_path << std::endl;
std::cout <<
" Verify peer: " << (tls_config.
verify_peer ?
"yes" :
"no") << std::endl;
std::cout << "\n3. Compile-time checks:" << std::endl;
static_assert(!policy::no_tls::enabled, "no_tls must have enabled=false");
static_assert(policy::tls_enabled::enabled, "tls_enabled must have enabled=true");
std::cout << " All static assertions passed" << std::endl;
std::cout << "\nDone." << std::endl;
return 0;
}
Main namespace for all Network System components.
Policy type indicating TLS/SSL encryption is enabled.
Policy-based TLS configuration (no_tls, require_tls, optional_tls).
void describe_policy(const std::string &label)