Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_network_sni.c File Reference
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_network.h"
#include "nilorea/n_str.h"
#include "nilorea/n_x509.h"
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <openssl/ssl.h>
#include <openssl/x509.h>
+ Include dependency graph for ex_network_sni.c:

Go to the source code of this file.

Data Structures

struct  CA_CTX
 CA used by the server to mint per-host leaves. More...
 
struct  SRV
 server worker context More...
 

Macros

#define MSG_LEN   18
 fixed exchange message length (both messages are 17 chars + NUL)
 
#define SNI_HOST   "test.host.example"
 the host name the client requests via SNI
 

Functions

static NETWORKbind_free (char *port_out, size_t port_out_len)
 
int main (int argc, char **argv)
 
static int pick_cb (const char *sni, N_STR **cert_pem, N_STR **key_pem, void *user_data)
 
void process_args (int argc, char **argv)
 
static void * server_fn (void *p)
 

Data Structure Documentation

◆ CA_CTX

struct CA_CTX

CA used by the server to mint per-host leaves.

Examples
ex_network_sni.c.

Definition at line 48 of file ex_network_sni.c.

+ Collaboration diagram for CA_CTX:
Data Fields
N_STR * cert
N_STR * key

◆ SRV

struct SRV

server worker context

Examples
ex_network_sni.c.

Definition at line 54 of file ex_network_sni.c.

+ Collaboration diagram for SRV:
Data Fields
CA_CTX * ca
NETWORK * listen
int ok

Macro Definition Documentation

◆ MSG_LEN

#define MSG_LEN   18

fixed exchange message length (both messages are 17 chars + NUL)

Examples
ex_network_sni.c.

Definition at line 45 of file ex_network_sni.c.

◆ SNI_HOST

#define SNI_HOST   "test.host.example"

the host name the client requests via SNI

Examples
ex_network_sni.c.

Definition at line 43 of file ex_network_sni.c.

Function Documentation

◆ bind_free()

static NETWORK * bind_free ( char *  port_out,
size_t  port_out_len 
)
static
Examples
ex_network_sni.c.

Definition at line 119 of file ex_network_sni.c.

References netw_close(), netw_make_listening(), and NETWORK_IPALL.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

◆ pick_cb()

static int pick_cb ( const char *  sni,
N_STR **  cert_pem,
N_STR **  key_pem,
void *  user_data 
)
static
Examples
ex_network_sni.c.

Definition at line 93 of file ex_network_sni.c.

References CA_CTX::cert, CA_CTX::key, LOG_DEBUG, n_log, and n_x509_mint_host_cert().

Referenced by server_fn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process_args()

void process_args ( int  argc,
char **  argv 
)

Definition at line 61 of file ex_network_sni.c.

References LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_NOTICE, LOG_NULL, and set_log_level().

+ Here is the call graph for this function:

◆ server_fn()

static void * server_fn ( void *  p)
static
Examples
ex_network_sni.c.

Definition at line 101 of file ex_network_sni.c.

References SRV::ca, SRV::listen, LOG_NOTICE, MSG_LEN, n_log, netw_accept_ssl_with_sni_cb(), netw_close(), SRV::ok, pick_cb(), recv_ssl_data(), and send_ssl_data().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: