Dillo v3.1.1-46-g8a360e32
Loading...
Searching...
No Matches
tls_openssl.c File Reference
#include "config.h"
#include "../msg.h"
#include <assert.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include "../../dlib/dlib.h"
#include "../dialog.hh"
#include "../klist.h"
#include "iowatch.hh"
#include "tls.h"
#include "Url.h"
#include <openssl/ssl.h>
#include <openssl/rand.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
#include <openssl/crypto.h>
Include dependency graph for tls_openssl.c:

Go to the source code of this file.

Macros

#define CERT_STATUS_NONE   0
 
#define CERT_STATUS_RECEIVING   1
 
#define CERT_STATUS_CLEAN   2
 
#define CERT_STATUS_BAD   3
 
#define CERT_STATUS_USER_ACCEPTED   4
 
#define ASTERISK_EXCLUDES_DOT   /* mandated by rfc2818 */
 

Functions

static void Tls_connect_cb (int fd, void *vconnkey)
 
static int Tls_fd_map_cmp (const void *v1, const void *v2)
 
static void Tls_fd_map_add_entry (int fd, int connkey)
 
static void Tls_fd_map_remove_entry (int fd)
 
void * a_Tls_openssl_connection (int fd)
 
static int Tls_conn_new (int fd, const DilloUrl *url, SSL *ssl)
 
static void Tls_info_cb (const SSL *ssl, int where, int ret)
 
static void Tls_load_certificates (void)
 
void a_Tls_openssl_init (void)
 
static int Tls_save_certificate_home (X509 *cert)
 
static int Tls_servers_cmp (const void *v1, const void *v2)
 
static int Tls_servers_by_url_cmp (const void *v1, const void *v2)
 
int a_Tls_openssl_connect_ready (const DilloUrl *url)
 
static int Tls_cert_status (const DilloUrl *url)
 
static int Tls_user_said_no (const DilloUrl *url)
 
int a_Tls_openssl_certificate_is_clean (const DilloUrl *url)
 
static bool_t Tls_check_cert_strength (SSL *ssl, Server_t *srv, int *choice)
 
static bool_t pattern_match (const char *pattern, const char *string)
 
static bool_t Tls_check_cert_hostname (X509 *cert, const char *host, int *choice)
 
static X509 * Tls_get_end_of_chain (SSL *ssl)
 
static void Tls_get_issuer_name (X509 *cert, char *buf, uint_t buflen)
 
static void Tls_get_expiration_str (X509 *cert, char *buf, uint_t buflen)
 
static int Tls_examine_certificate (SSL *ssl, Server_t *srv)
 
void a_Tls_openssl_reset_server_state (const DilloUrl *url)
 
static void Tls_close_by_key (int connkey)
 
static void Tls_connect (int fd, int connkey)
 
void a_Tls_openssl_connect (int fd, const DilloUrl *url)
 
static int Tls_handle_error (Conn_t *conn, int ret, const char *where)
 
int a_Tls_openssl_read (void *conn, void *buf, size_t len)
 
int a_Tls_openssl_write (void *conn, void *buf, size_t len)
 
void a_Tls_openssl_close_by_fd (int fd)
 
static void Tls_servers_freeall (void)
 
static void Tls_fd_map_remove_all (void)
 
void a_Tls_openssl_freeall (void)
 

Variables

static Klist_tconn_list = NULL
 
static SSL_CTX * ssl_context
 
static Dlistservers
 
static Dlistfd_map
 

Macro Definition Documentation

◆ ASTERISK_EXCLUDES_DOT

#define ASTERISK_EXCLUDES_DOT   /* mandated by rfc2818 */

Definition at line 537 of file tls_openssl.c.

◆ CERT_STATUS_BAD

#define CERT_STATUS_BAD   3

Definition at line 61 of file tls_openssl.c.

◆ CERT_STATUS_CLEAN

#define CERT_STATUS_CLEAN   2

Definition at line 60 of file tls_openssl.c.

◆ CERT_STATUS_NONE

#define CERT_STATUS_NONE   0

Definition at line 58 of file tls_openssl.c.

◆ CERT_STATUS_RECEIVING

#define CERT_STATUS_RECEIVING   1

Definition at line 59 of file tls_openssl.c.

◆ CERT_STATUS_USER_ACCEPTED

#define CERT_STATUS_USER_ACCEPTED   4

Definition at line 62 of file tls_openssl.c.

Function Documentation

◆ a_Tls_openssl_certificate_is_clean()

int a_Tls_openssl_certificate_is_clean ( const DilloUrl url)

Definition at line 424 of file tls_openssl.c.

References CERT_STATUS_CLEAN, and Tls_cert_status().

Referenced by a_Tls_certificate_is_clean().

◆ a_Tls_openssl_close_by_fd()

void a_Tls_openssl_close_by_fd ( int  fd)

Definition at line 1331 of file tls_openssl.c.

References dList_find_custom(), fd_map, INT2VOIDP, Tls_close_by_key(), and Tls_fd_map_cmp().

Referenced by a_Tls_close_by_fd().

◆ a_Tls_openssl_connect()

void a_Tls_openssl_connect ( int  fd,
const DilloUrl url 
)

◆ a_Tls_openssl_connect_ready()

◆ a_Tls_openssl_connection()

void * a_Tls_openssl_connection ( int  fd)

Definition at line 145 of file tls_openssl.c.

References a_Klist_get_data(), conn_list, dList_find_custom(), fd_map, INT2VOIDP, and Tls_fd_map_cmp().

Referenced by a_Tls_connection().

◆ a_Tls_openssl_freeall()

void a_Tls_openssl_freeall ( void  )

Definition at line 1373 of file tls_openssl.c.

References ssl_context, Tls_fd_map_remove_all(), and Tls_servers_freeall().

Referenced by a_Tls_freeall().

◆ a_Tls_openssl_init()

void a_Tls_openssl_init ( void  )

Definition at line 252 of file tls_openssl.c.

References dList_new(), fd_map, MSG, MSG_ERR, servers, ssl_context, Tls_info_cb(), and Tls_load_certificates().

Referenced by a_Tls_init().

◆ a_Tls_openssl_read()

int a_Tls_openssl_read ( void *  conn,
void *  buf,
size_t  len 
)

Definition at line 1316 of file tls_openssl.c.

References Tls_handle_error().

Referenced by a_Tls_read().

◆ a_Tls_openssl_reset_server_state()

void a_Tls_openssl_reset_server_state ( const DilloUrl url)

◆ a_Tls_openssl_write()

int a_Tls_openssl_write ( void *  conn,
void *  buf,
size_t  len 
)

Definition at line 1325 of file tls_openssl.c.

References Tls_handle_error().

Referenced by a_Tls_write().

◆ pattern_match()

static bool_t pattern_match ( const char *  pattern,
const char *  string 
)
static

Definition at line 553 of file tls_openssl.c.

References FALSE, pattern_match(), and TRUE.

Referenced by pattern_match(), and Tls_check_cert_hostname().

◆ Tls_cert_status()

static int Tls_cert_status ( const DilloUrl url)
static

◆ Tls_check_cert_hostname()

static bool_t Tls_check_cert_hostname ( X509 *  cert,
const char *  host,
int *  choice 
)
static

◆ Tls_check_cert_strength()

static bool_t Tls_check_cert_strength ( SSL *  ssl,
Server_t *  srv,
int *  choice 
)
static

Definition at line 439 of file tls_openssl.c.

References a_Dialog_choice(), CERT_STATUS_RECEIVING, FALSE, MSG, MSG_WARN, and TRUE.

Referenced by Tls_examine_certificate().

◆ Tls_close_by_key()

◆ Tls_conn_new()

static int Tls_conn_new ( int  fd,
const DilloUrl url,
SSL *  ssl 
)
static

Definition at line 162 of file tls_openssl.c.

References a_Klist_insert(), a_Url_dup(), conn_list, dNew0, FALSE, Tls_fd_map_add_entry(), and TRUE.

Referenced by a_Tls_openssl_connect().

◆ Tls_connect()

◆ Tls_connect_cb()

static void Tls_connect_cb ( int  fd,
void *  vconnkey 
)
static

Definition at line 1201 of file tls_openssl.c.

References Tls_connect(), and VOIDP2INT.

Referenced by Tls_connect().

◆ Tls_examine_certificate()

◆ Tls_fd_map_add_entry()

static void Tls_fd_map_add_entry ( int  fd,
int  connkey 
)
static

Definition at line 110 of file tls_openssl.c.

References dList_append(), dList_find_custom(), dNew0, fd_map, INT2VOIDP, MSG_ERR, and Tls_fd_map_cmp().

Referenced by Tls_conn_new().

◆ Tls_fd_map_cmp()

static int Tls_fd_map_cmp ( const void *  v1,
const void *  v2 
)
static

◆ Tls_fd_map_remove_all()

static void Tls_fd_map_remove_all ( void  )
static

Definition at line 1356 of file tls_openssl.c.

References dFree(), dList_free(), dList_length(), dList_nth_data(), and fd_map.

Referenced by a_Tls_openssl_freeall().

◆ Tls_fd_map_remove_entry()

static void Tls_fd_map_remove_entry ( int  fd)
static

Definition at line 128 of file tls_openssl.c.

References dFree(), dList_find_custom(), dList_remove_fast(), fd_map, INT2VOIDP, MSG, and Tls_fd_map_cmp().

Referenced by Tls_close_by_key().

◆ Tls_get_end_of_chain()

static X509 * Tls_get_end_of_chain ( SSL *  ssl)
static

Definition at line 778 of file tls_openssl.c.

Referenced by Tls_examine_certificate().

◆ Tls_get_expiration_str()

static void Tls_get_expiration_str ( X509 *  cert,
char *  buf,
uint_t  buflen 
)
static

Definition at line 795 of file tls_openssl.c.

Referenced by Tls_examine_certificate().

◆ Tls_get_issuer_name()

static void Tls_get_issuer_name ( X509 *  cert,
char *  buf,
uint_t  buflen 
)
static

Definition at line 785 of file tls_openssl.c.

Referenced by Tls_examine_certificate().

◆ Tls_handle_error()

static int Tls_handle_error ( Conn_t *  conn,
int  ret,
const char *  where 
)
static

Definition at line 1273 of file tls_openssl.c.

References FALSE, and MSG.

Referenced by a_Tls_openssl_read(), and a_Tls_openssl_write().

◆ Tls_info_cb()

static void Tls_info_cb ( const SSL *  ssl,
int  where,
int  ret 
)
static

Definition at line 184 of file tls_openssl.c.

References MSG.

Referenced by a_Tls_openssl_init().

◆ Tls_load_certificates()

static void Tls_load_certificates ( void  )
static

Definition at line 202 of file tls_openssl.c.

References dFree(), dGethomedir(), dStrconcat(), and ssl_context.

Referenced by a_Tls_openssl_init().

◆ Tls_save_certificate_home()

static int Tls_save_certificate_home ( X509 *  cert)
static

Definition at line 301 of file tls_openssl.c.

References dGethomedir(), and MSG.

Referenced by Tls_examine_certificate().

◆ Tls_servers_by_url_cmp()

static int Tls_servers_by_url_cmp ( const void *  v1,
const void *  v2 
)
static

◆ Tls_servers_cmp()

static int Tls_servers_cmp ( const void *  v1,
const void *  v2 
)
static

Definition at line 346 of file tls_openssl.c.

References dStrAsciiCasecmp().

Referenced by a_Tls_openssl_connect_ready().

◆ Tls_servers_freeall()

static void Tls_servers_freeall ( void  )
static

Definition at line 1341 of file tls_openssl.c.

References dFree(), dList_free(), dList_length(), dList_nth_data(), and servers.

Referenced by a_Tls_openssl_freeall().

◆ Tls_user_said_no()

static int Tls_user_said_no ( const DilloUrl url)
static

Definition at line 415 of file tls_openssl.c.

References CERT_STATUS_BAD, and Tls_cert_status().

Referenced by a_Tls_openssl_connect().

Variable Documentation

◆ conn_list

Klist_t* conn_list = NULL
static

◆ fd_map

◆ servers

◆ ssl_context