FreeRDP
crypto/certificate.c File Reference
#include <winpr/assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <winpr/crypto.h>
#include <winpr/crt.h>
#include <winpr/file.h>
#include <winpr/path.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
#include <freerdp/settings.h>
#include <freerdp/crypto/certificate.h>
#include <freerdp/log.h>

Macros

#define TAG   FREERDP_TAG("crypto")
 
#define check_certificate_store_and_data(store, data)   check_certificate_store_and_data_((store), (data), __FILE__, __FUNCTION__, __LINE__)
 

Functions

static BOOL certificate_get_file_data (rdpCertificateStore *store, rdpCertificateData *data)
 
static BOOL duplicate (char **data, const char *value)
 
static HANDLE open_file (const char *name, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes)
 
static rdpCertificateData * certificate_split_line (char *line)
 
static BOOL certificate_line_is_comment (const char *line, size_t length)
 
static void certificate_store_uninit (rdpCertificateStore *certificate_store)
 
static BOOL ensure_path_exists (const char *path)
 
static BOOL certificate_store_init (rdpCertificateStore *certificate_store)
 
static int compare_pem (const char *current, const char *stored)
 
static int certificate_data_match_raw (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data, char **psubject, char **pissuer, char **fprint, char **ppem)
 
static WCHAR * certificate_get_cert_file_name (rdpCertificateStore *store, const rdpCertificateData *data)
 
static rdpCertificateData * load_from_file (rdpCertificateStore *store, const char *hostname, UINT16 port)
 
static int certificate_match_data_file (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data)
 
static BOOL useKnownHosts (rdpCertificateStore *certificate_store)
 
static BOOL check_certificate_store_and_data_ (const rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data, const char *file, const char *fkt, size_t line)
 
int certificate_store_contains_data (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data)
 
static char * decode (const char *value)
 
static char * encode (const char *value)
 
static char * allocated_printf (const char *fmt,...)
 
static char * certificate_data_get_host_file_entry (const rdpCertificateData *data)
 
static BOOL write_line_and_free (const char *filename, HANDLE fp, char *line)
 
static BOOL certificate_data_replace_hosts_file (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data, BOOL remove, BOOL append)
 
static BOOL certificate_data_write_to_file (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data)
 
static BOOL certificate_data_remove_file (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data)
 
BOOL certificate_store_remove_data (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data)
 
static BOOL update_from_pem (rdpCertificateData *data)
 
BOOL certificate_store_save_data (rdpCertificateStore *certificate_store, const rdpCertificateData *certificate_data)
 
rdpCertificateData * certificate_store_load_data (rdpCertificateStore *certificate_store, const char *host, UINT16 port)
 
rdpCertificateData * certificate_data_new (const char *hostname, UINT16 port)
 
void certificate_data_free (rdpCertificateData *certificate_data)
 
const char * certificate_data_get_host (const rdpCertificateData *cert)
 
UINT16 certificate_data_get_port (const rdpCertificateData *cert)
 
BOOL certificate_data_set_pem (rdpCertificateData *cert, const char *pem)
 
BOOL certificate_data_set_subject (rdpCertificateData *cert, const char *subject)
 
BOOL certificate_data_set_issuer (rdpCertificateData *cert, const char *issuer)
 
BOOL certificate_data_set_fingerprint (rdpCertificateData *cert, const char *fingerprint)
 
const char * certificate_data_get_pem (const rdpCertificateData *cert)
 
const char * certificate_data_get_subject (const rdpCertificateData *cert)
 
const char * certificate_data_get_issuer (const rdpCertificateData *cert)
 
const char * certificate_data_get_fingerprint (const rdpCertificateData *cert)
 
rdpCertificateStore * certificate_store_new (const rdpSettings *settings)
 
void certificate_store_free (rdpCertificateStore *certstore)
 
const char * certificate_store_get_hosts_file (const rdpCertificateStore *certificate_store)
 
const char * certificate_store_get_certs_path (const rdpCertificateStore *certificate_store)
 
const char * certificate_store_get_hosts_path (const rdpCertificateStore *certificate_store)
 

Variables

static const char certificate_store_dir [] = "certs"
 
static const char certificate_server_dir [] = "server"
 
static const char certificate_known_hosts_file [] = "known_hosts2"
 

Macro Definition Documentation

◆ check_certificate_store_and_data

#define check_certificate_store_and_data (   store,
  data 
)    check_certificate_store_and_data_((store), (data), __FILE__, __FUNCTION__, __LINE__)

◆ TAG

#define TAG   FREERDP_TAG("crypto")

Function Documentation

◆ allocated_printf()

static char* allocated_printf ( const char *  fmt,
  ... 
)
static
Here is the caller graph for this function:

◆ certificate_data_free()

void certificate_data_free ( rdpCertificateData *  certificate_data)
Here is the caller graph for this function:

◆ certificate_data_get_fingerprint()

const char* certificate_data_get_fingerprint ( const rdpCertificateData *  cert)
Here is the caller graph for this function:

◆ certificate_data_get_host()

const char* certificate_data_get_host ( const rdpCertificateData *  cert)
Here is the caller graph for this function:

◆ certificate_data_get_host_file_entry()

static char* certificate_data_get_host_file_entry ( const rdpCertificateData *  data)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_get_issuer()

const char* certificate_data_get_issuer ( const rdpCertificateData *  cert)
Here is the caller graph for this function:

◆ certificate_data_get_pem()

const char* certificate_data_get_pem ( const rdpCertificateData *  cert)
Here is the caller graph for this function:

◆ certificate_data_get_port()

UINT16 certificate_data_get_port ( const rdpCertificateData *  cert)
Here is the caller graph for this function:

◆ certificate_data_get_subject()

const char* certificate_data_get_subject ( const rdpCertificateData *  cert)
Here is the caller graph for this function:

◆ certificate_data_match_raw()

static int certificate_data_match_raw ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data,
char **  psubject,
char **  pissuer,
char **  fprint,
char **  ppem 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_new()

rdpCertificateData* certificate_data_new ( const char *  hostname,
UINT16  port 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_remove_file()

static BOOL certificate_data_remove_file ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_replace_hosts_file()

static BOOL certificate_data_replace_hosts_file ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data,
BOOL  remove,
BOOL  append 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_set_fingerprint()

BOOL certificate_data_set_fingerprint ( rdpCertificateData *  cert,
const char *  fingerprint 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_set_issuer()

BOOL certificate_data_set_issuer ( rdpCertificateData *  cert,
const char *  issuer 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_set_pem()

BOOL certificate_data_set_pem ( rdpCertificateData *  cert,
const char *  pem 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_set_subject()

BOOL certificate_data_set_subject ( rdpCertificateData *  cert,
const char *  subject 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_data_write_to_file()

static BOOL certificate_data_write_to_file ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_get_cert_file_name()

static WCHAR* certificate_get_cert_file_name ( rdpCertificateStore *  store,
const rdpCertificateData *  data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_get_file_data()

static BOOL certificate_get_file_data ( rdpCertificateStore *  store,
rdpCertificateData *  data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_line_is_comment()

static BOOL certificate_line_is_comment ( const char *  line,
size_t  length 
)
static
Here is the caller graph for this function:

◆ certificate_match_data_file()

static int certificate_match_data_file ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_split_line()

rdpCertificateData * certificate_split_line ( char *  line)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_contains_data()

int certificate_store_contains_data ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_free()

void certificate_store_free ( rdpCertificateStore *  certstore)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_get_certs_path()

const char* certificate_store_get_certs_path ( const rdpCertificateStore *  certificate_store)
Here is the caller graph for this function:

◆ certificate_store_get_hosts_file()

const char* certificate_store_get_hosts_file ( const rdpCertificateStore *  certificate_store)
Here is the caller graph for this function:

◆ certificate_store_get_hosts_path()

const char* certificate_store_get_hosts_path ( const rdpCertificateStore *  certificate_store)

◆ certificate_store_init()

static BOOL certificate_store_init ( rdpCertificateStore *  certificate_store)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_load_data()

rdpCertificateData* certificate_store_load_data ( rdpCertificateStore *  certificate_store,
const char *  host,
UINT16  port 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_new()

rdpCertificateStore* certificate_store_new ( const rdpSettings *  settings)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_remove_data()

BOOL certificate_store_remove_data ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_save_data()

BOOL certificate_store_save_data ( rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ certificate_store_uninit()

static void certificate_store_uninit ( rdpCertificateStore *  certificate_store)
static
Here is the caller graph for this function:

◆ check_certificate_store_and_data_()

static BOOL check_certificate_store_and_data_ ( const rdpCertificateStore *  certificate_store,
const rdpCertificateData *  certificate_data,
const char *  file,
const char *  fkt,
size_t  line 
)
static
Here is the call graph for this function:

◆ compare_pem()

static int compare_pem ( const char *  current,
const char *  stored 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decode()

static char* decode ( const char *  value)
static
Here is the call graph for this function:

◆ duplicate()

static BOOL duplicate ( char **  data,
const char *  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ encode()

static char* encode ( const char *  value)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ensure_path_exists()

static BOOL ensure_path_exists ( const char *  path)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_from_file()

static rdpCertificateData* load_from_file ( rdpCertificateStore *  store,
const char *  hostname,
UINT16  port 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_file()

static HANDLE open_file ( const char *  name,
DWORD  dwDesiredAccess,
DWORD  dwShareMode,
DWORD  dwCreationDisposition,
DWORD  dwFlagsAndAttributes 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_from_pem()

static BOOL update_from_pem ( rdpCertificateData *  data)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ useKnownHosts()

static BOOL useKnownHosts ( rdpCertificateStore *  certificate_store)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_line_and_free()

static BOOL write_line_and_free ( const char *  filename,
HANDLE  fp,
char *  line 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ certificate_known_hosts_file

const char certificate_known_hosts_file[] = "known_hosts2"
static

◆ certificate_server_dir

const char certificate_server_dir[] = "server"
static

◆ certificate_store_dir

const char certificate_store_dir[] = "certs"
static