tls_init.c File Reference

Kamailio TLS support :: Initialization

Module: Kamailio TLS support. More...

#include <stdio.h>
#include "tls_init.h"
#include "tls_config.h"
#include "../dprint.h"
#include "../mem/shm_mem.h"
#include "../tcp_init.h"
#include "../ut.h"
#include "tls_domain.h"
#include <openssl/ui.h>
#include <openssl/ssl.h>
#include <openssl/opensslv.h>
#include <openssl/err.h>
#include <openssl/comp.h>
#include <netinet/in_systm.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <unistd.h>

Include dependency graph for tls_init.c:

Go to the source code of this file.

Defines

#define NUM_RETRIES   3
#define SER_SSL_SESS_ID   ((unsigned char*)"Kamailio-tls")
#define SER_SSL_SESS_ID_LEN   (sizeof(SER_SSL_SESS_ID)-1)
#define VERIFY_DEPTH_S   3

Functions

static int check_for_krb (void)
void destroy_tls (void)
 called from main.c when kamailio exits (main process)
static int init_ssl_ctx_behavior (struct tls_domain *d)
 Setup default SSL_CTX (and SSL * ) behavior: verification, cipherlist, acceptable versions, ...
static void init_ssl_methods (void)
 initialize ssl methods
int init_tls (void)
 called once from main.c (main process)
int init_tls_domains (struct tls_domain *d)
 initialize tls virtual domains
static int load_ca (SSL_CTX *ctx, char *filename)
 Load a caList, to be used to verify the client's certificate. The list is to be stored in a single file, containing all the acceptable root certificates.
static int load_certificate (SSL_CTX *ctx, char *filename)
 load a certificate from a file (certificate file can be a chain, starting by the user cert, and ending in the root CA; if not all needed certs are in this file, they are looked up in the caFile or caPATH (see verify function).
static int load_private_key (SSL_CTX *ctx, char *filename)
 load a private key from a file
static int passwd_cb (char *buf, int size, int rwflag, void *filename)
int pre_init_tls (void)
 called once from main.c (main process) before parsing the configuration
static void ser_free (void *ptr)
static void * ser_malloc (size_t size)
static void * ser_realloc (void *ptr, size_t size)
int tls_init (struct socket_info *si)
int verify_callback (int pre_verify_ok, X509_STORE_CTX *ctx)
 This callback is called during each verification process, at each step during the chain of certificates (this function is not the certificate_verification one!).

Variables

SSL_METHOD * ssl_methods [TLS_USE_SSLv23+1]


Detailed Description

Kamailio TLS support :: Initialization

Module: Kamailio TLS support.

Definition in file tls_init.c.


Define Documentation

#define NUM_RETRIES   3

Definition at line 325 of file tls_init.c.

Referenced by load_private_key().

#define SER_SSL_SESS_ID   ((unsigned char*)"Kamailio-tls")

Definition at line 64 of file tls_init.c.

Referenced by init_ssl_ctx_behavior().

#define SER_SSL_SESS_ID_LEN   (sizeof(SER_SSL_SESS_ID)-1)

Definition at line 65 of file tls_init.c.

Referenced by init_ssl_ctx_behavior().

#define VERIFY_DEPTH_S   3

Definition at line 79 of file tls_init.c.

Referenced by init_ssl_ctx_behavior(), and verify_callback().


Function Documentation

static int check_for_krb ( void   )  [static]

Definition at line 530 of file tls_init.c.

References LM_INFO, NULL, and ssl_methods.

Referenced by init_tls().

void destroy_tls ( void   ) 

called from main.c when kamailio exits (main process)

just once before cleanup

Definition at line 754 of file tls_init.c.

References tls_domain::ctx, LM_DBG, tls_domain::next, tls_client_domains, tls_default_client_domain, tls_default_server_domain, tls_free_domains(), and tls_server_domains.

Referenced by cleanup().

static int init_ssl_ctx_behavior ( struct tls_domain d  )  [static]

Setup default SSL_CTX (and SSL * ) behavior: verification, cipherlist, acceptable versions, ...

Definition at line 415 of file tls_init.c.

References tls_domain::ciphers_list, tls_domain::ctx, LM_DBG, LM_ERR, LM_NOTICE, LM_WARN, tls_domain::require_client_cert, SER_SSL_SESS_ID, SER_SSL_SESS_ID_LEN, TLS_DOMAIN_SRV, tls_domain::type, verify_callback(), tls_domain::verify_cert, and VERIFY_DEPTH_S.

Referenced by init_tls_domains().

static void init_ssl_methods ( void   )  [static]

int init_tls ( void   ) 

called once from main.c (main process)

just once, initialize the tls subsystem

Definition at line 558 of file tls_init.c.

References check_for_krb(), init_ssl_methods(), init_tls_domains(), LM_DBG, LM_ERR, LM_INFO, LM_WARN, ser_free(), ser_malloc(), ser_realloc(), tls_client_domains, tls_default_client_domain, tls_default_server_domain, and tls_server_domains.

Referenced by main().

int init_tls_domains ( struct tls_domain d  ) 

static int load_ca ( SSL_CTX *  ctx,
char *  filename 
) [static]

Load a caList, to be used to verify the client's certificate. The list is to be stored in a single file, containing all the acceptable root certificates.

Definition at line 372 of file tls_init.c.

References LM_DBG, and LM_ERR.

Referenced by init_tls_domains().

static int load_certificate ( SSL_CTX *  ctx,
char *  filename 
) [static]

load a certificate from a file (certificate file can be a chain, starting by the user cert, and ending in the root CA; if not all needed certs are in this file, they are looked up in the caFile or caPATH (see verify function).

Definition at line 311 of file tls_init.c.

References LM_DBG, and LM_ERR.

Referenced by init_tls_domains().

static int load_private_key ( SSL_CTX *  ctx,
char *  filename 
) [static]

load a private key from a file

Definition at line 330 of file tls_init.c.

References LM_DBG, LM_ERR, NUM_RETRIES, and passwd_cb().

Referenced by init_tls_domains().

static int passwd_cb ( char *  buf,
int  size,
int  rwflag,
void *  filename 
) [static]

Definition at line 172 of file tls_init.c.

References LM_ERR, and NULL.

Referenced by load_private_key().

int pre_init_tls ( void   ) 

called once from main.c (main process) before parsing the configuration

Definition at line 790 of file tls_init.c.

References tls_domain::addr, ip_addr::af, LM_DBG, LM_ERR, tls_default_client_domain, tls_default_server_domain, TLS_DOMAIN_CLI, TLS_DOMAIN_DEF, TLS_DOMAIN_SRV, and tls_new_domain().

Referenced by main().

static void ser_free ( void *  ptr  )  [static]

Definition at line 273 of file tls_init.c.

References shm_free.

Referenced by init_tls().

static void* ser_malloc ( size_t  size  )  [static]

Definition at line 261 of file tls_init.c.

References shm_malloc().

Referenced by init_tls().

static void* ser_realloc ( void *  ptr,
size_t  size 
) [static]

Definition at line 267 of file tls_init.c.

References shm_realloc().

Referenced by init_tls().

int tls_init ( struct socket_info si  ) 

Definition at line 280 of file tls_init.c.

References LM_DBG, LM_ERR, socket_info::proto, PROTO_TLS, socket_info::socket, and tcp_init().

Referenced by main_loop().

int verify_callback ( int  pre_verify_ok,
X509_STORE_CTX *  ctx 
)

This callback is called during each verification process, at each step during the chain of certificates (this function is not the certificate_verification one!).

Definition at line 84 of file tls_init.c.

References buf, LM_NOTICE, and VERIFY_DEPTH_S.

Referenced by init_ssl_ctx_behavior().


Variable Documentation

SSL_METHOD* ssl_methods[TLS_USE_SSLv23+1]

Definition at line 77 of file tls_init.c.

Referenced by check_for_krb(), init_ssl_methods(), and init_tls_domains().


Generated on Thu May 24 20:00:44 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6