Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
tls_policy_example.cpp File Reference

Demonstrates TLS policy configuration for secure connections. More...

#include <kcenon/network/policy/tls_policy.h>
#include <iostream>
#include <string>
Include dependency graph for tls_policy_example.cpp:

Go to the source code of this file.

Functions

template<typename TlsPolicy >
void describe_policy (const std::string &label)
 
int main ()
 

Detailed Description

Demonstrates TLS policy configuration for secure connections.

Definition in file tls_policy_example.cpp.

Function Documentation

◆ describe_policy()

template<typename TlsPolicy >
void describe_policy ( const std::string & label)
Examples
tls_policy_example.cpp.

Definition at line 34 of file tls_policy_example.cpp.

35{
36 std::cout << " " << label << ": TLS "
37 << (TlsPolicy::enabled ? "enabled" : "disabled") << std::endl;
38}

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 40 of file tls_policy_example.cpp.

41{
42 std::cout << "=== TLS Policy Example ===" << std::endl;
43
44 // 1. No TLS (plain-text)
45 std::cout << "\n1. Compile-time policy inspection:" << std::endl;
48
49 // 2. TLS configuration
50 std::cout << "\n2. TLS enabled configuration:" << std::endl;
51 policy::tls_enabled tls_config;
52 tls_config.cert_path = "/etc/ssl/certs/server.crt";
53 tls_config.key_path = "/etc/ssl/private/server.key";
54 tls_config.ca_path = "/etc/ssl/certs/ca-bundle.crt";
55 tls_config.verify_peer = true;
56
57 std::cout << " Certificate: " << tls_config.cert_path << std::endl;
58 std::cout << " Private key: " << tls_config.key_path << std::endl;
59 std::cout << " CA bundle: " << tls_config.ca_path << std::endl;
60 std::cout << " Verify peer: " << (tls_config.verify_peer ? "yes" : "no") << std::endl;
61
62 // 3. Static assertions
63 std::cout << "\n3. Compile-time checks:" << std::endl;
64 static_assert(!policy::no_tls::enabled, "no_tls must have enabled=false");
65 static_assert(policy::tls_enabled::enabled, "tls_enabled must have enabled=true");
66 std::cout << " All static assertions passed" << std::endl;
67
68 std::cout << "\nDone." << std::endl;
69 return 0;
70}
static constexpr bool enabled
Definition tls_policy.h:40
Policy type indicating TLS/SSL encryption is enabled.
Definition tls_policy.h:61
static constexpr bool enabled
Definition tls_policy.h:62
void describe_policy(const std::string &label)

References kcenon::network::policy::tls_enabled::ca_path, kcenon::network::policy::tls_enabled::cert_path, describe_policy(), kcenon::network::policy::no_tls::enabled, kcenon::network::policy::tls_enabled::enabled, kcenon::network::policy::tls_enabled::key_path, and kcenon::network::policy::tls_enabled::verify_peer.

Here is the call graph for this function: