27# error "ENABLE_TLS not defined"
33#include "../../dlib/dlib.h"
34#include "../dialog.hh"
40#include <mbedtls/platform.h>
41#include <mbedtls/ssl.h>
42#include <mbedtls/ctr_drbg.h>
43#include <mbedtls/entropy.h>
44#include <mbedtls/error.h>
45#include <mbedtls/oid.h>
46#include <mbedtls/x509.h>
47#include <mbedtls/version.h>
48#if MBEDTLS_VERSION_NUMBER < 0x03000000
49#include <mbedtls/net.h>
51#include <mbedtls/net_sockets.h>
54#define CERT_STATUS_NONE 0
55#define CERT_STATUS_RECEIVING 1
56#define CERT_STATUS_CLEAN 2
57#define CERT_STATUS_BAD 3
58#define CERT_STATUS_USER_ACCEPTED 4
82 mbedtls_ssl_context *ssl;
102#if MBEDTLS_VERSION_NUMBER >= 0x03060000
104int mbedtls_ssl_ciphersuite_uses_psk(
const mbedtls_ssl_ciphersuite_t *info);
113 const FdMapEntry_t *e = v1;
115 return (fd != e->fd);
120 FdMapEntry_t *e =
dNew0(FdMapEntry_t, 1);
122 e->connkey = connkey;
125 MSG_ERR(
"TLS FD ENTRY ALREADY FOUND FOR %d\n", e->fd);
145 MSG(
"TLS FD ENTRY NOT FOUND FOR %d\n", fd);
171 mbedtls_ssl_context *ssl)
173 Conn_t *conn =
dNew0(Conn_t, 1);
177 conn->connecting =
TRUE;
195 int ret = mbedtls_x509_crt_parse_file(&
cacerts, filename);
198 if (ret == MBEDTLS_ERR_PK_FILE_IO_ERROR) {
201 MSG(
"Failed to parse certificates from %s (returned -0x%04x)\n",
212 int ret = mbedtls_x509_crt_parse_path(&
cacerts, pathname);
215 if (ret == MBEDTLS_ERR_X509_FILE_IO_ERROR) {
218 MSG(
"Failed to parse certificates from %s (returned -0x%04x)\n",
229 mbedtls_x509_crt *cp, *curr = &
cacerts;
234 if (curr->serial.len == cp->next->serial.len &&
235 !memcmp(curr->serial.p, cp->next->serial.p, curr->serial.len) &&
236 curr->subject_raw.len == cp->next->subject_raw.len &&
237 !memcmp(curr->subject_raw.p, cp->next->subject_raw.p,
238 curr->subject_raw.len)) {
239 mbedtls_x509_crt *duplicate = cp->next;
241 cp->next = duplicate->next;
246 duplicate->next = NULL;
247 mbedtls_x509_crt_free(duplicate);
270 mbedtls_x509_crt *curr;
272 static const char *
const ca_files[] = {
273 "/etc/ssl/certs/ca-certificates.crt",
274 "/etc/pki/tls/certs/ca-bundle.crt",
275 "/usr/share/ssl/certs/ca-bundle.crt",
276 "/usr/local/share/certs/ca-root.crt",
281 static const char *
const ca_paths[] = {
286 for (u = 0; u <
sizeof(ca_files)/
sizeof(ca_files[0]); u++) {
291 for (u = 0; u <
sizeof(ca_paths)/
sizeof(ca_paths[0]); u++) {
307 for (curr =
cacerts.next; curr; curr = curr->next)
310 mbedtls_x509_crt empty;
311 mbedtls_x509_crt_init(&empty);
313 if (memcmp(&
cacerts, &empty,
sizeof(mbedtls_x509_crt)))
317 MSG(
"Trusting %u TLS certificate%s.\n", u, u==1 ?
"" :
"s");
326 const mbedtls_ssl_ciphersuite_t *cs_info;
327 int *our_ciphers, *q;
330 const int *default_ciphers = mbedtls_ssl_list_ciphersuites(),
331 *p = default_ciphers;
335 cs_info = mbedtls_ssl_ciphersuite_from_id(*p);
336 if (!mbedtls_ssl_ciphersuite_uses_psk(cs_info))
341 our_ciphers =
dNew(
int, n);
347 cs_info = mbedtls_ssl_ciphersuite_from_id(*p);
349 if (!mbedtls_ssl_ciphersuite_uses_psk(cs_info))
355 mbedtls_ssl_conf_ciphersuites(&
ssl_conf, our_ciphers);
365 mbedtls_version_get_string_full(version);
366 MSG(
"TLS library: %s\n", version);
378 static const mbedtls_x509_crt_profile prof = {
379 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ) |
380 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) |
381 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ) |
382 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA512 ),
390 mbedtls_ssl_config_defaults(&
ssl_conf, MBEDTLS_SSL_IS_CLIENT,
391 MBEDTLS_SSL_TRANSPORT_STREAM,
392 MBEDTLS_SSL_PRESET_DEFAULT);
393 mbedtls_ssl_conf_cert_profile(&
ssl_conf, &prof);
400#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
401 mbedtls_ssl_conf_max_tls_version(&
ssl_conf, MBEDTLS_SSL_VERSION_TLS1_2);
408 mbedtls_ssl_conf_session_tickets(&
ssl_conf,
409 MBEDTLS_SSL_SESSION_TICKETS_DISABLED);
413 mbedtls_x509_crt_init(&
cacerts);
416 mbedtls_entropy_init(&
entropy);
418 if((ret = mbedtls_ctr_drbg_seed(&
ctr_drbg, mbedtls_entropy_func, &
entropy,
419 (
unsigned char*)
"dillo tls", 9))) {
421 MSG_ERR(
"tls: mbedtls_ctr_drbg_seed() failed. TLS disabled.\n");
425 mbedtls_ssl_conf_authmode(&
ssl_conf, MBEDTLS_SSL_VERIFY_OPTIONAL);
441 const Server_t *s1 = (
const Server_t *)v1, *s2 = (
const Server_t *)v2;
445 cmp = s1->port - s2->port;
453 const Server_t *s = (
const Server_t *)v1;
486 s =
dNew(Server_t, 1);
525static void Tls_print_cert_chain(
const mbedtls_x509_crt *cert)
528 const mbedtls_x509_crt *last_cert;
529 const uint_t buflen = 2048;
535 if (cert->sig_md == MBEDTLS_MD_SHA1) {
536 MSG_WARN(
"In 2015, browsers have begun to deprecate SHA1 "
540 if (mbedtls_oid_get_sig_alg_desc(&cert->sig_oid, &sigalg))
543 key_bits = mbedtls_pk_get_bitlen(&cert->pk);
544 mbedtls_x509_dn_gets(buf, buflen, &cert->subject);
545 MSG(
"%d-bit %s: %s\n", key_bits, sigalg, buf);
551 mbedtls_x509_dn_gets(buf, buflen, &last_cert->issuer);
552 MSG(
"root: %s\n", buf);
562 const mbedtls_x509_time *date = &cert->valid_to;
564 dStr_sprintfa(ds,
"Certificate expired at: %04d/%02d/%02d %02d:%02d:%02d.\n",
565 date->year, date->mon, date->day, date->hour, date->min,
574 const uint_t buflen = 2048;
575 char cert_info_buf[buflen];
578 dStr_append(ds,
"This host is not one of the hostnames listed on the TLS "
579 "certificate that it sent");
591 mbedtls_x509_crt_info(cert_info_buf, buflen,
"", cert);
593 if ((san = strstr(cert_info_buf,
"subject alt name : "))) {
595 s = strchr(san,
'\n');
609 const uint_t buflen = 2048;
614 mbedtls_x509_dn_gets(buf, buflen, &cert->issuer);
616 dStr_sprintfa(ds,
"Couldn't reach any trusted root certificate from "
617 "supplied certificate. The issuer at the end of the "
618 "chain was: \"%s\"\n", buf);
626 const mbedtls_x509_time *date = &cert->valid_to;
628 dStr_sprintfa(ds,
"Certificate validity begins in the future at: "
629 "%04d/%02d/%02d %02d:%02d:%02d.\n",
630 date->year, date->mon, date->day, date->hour, date->min,
639#if MBEDTLS_VERSION_NUMBER < 0x03000000
640 mbedtls_md_type_t md = cert->sig_md;
642 mbedtls_md_type_t md = cert->MBEDTLS_PRIVATE(sig_md);
644 const char *hash = (md == MBEDTLS_MD_MD5) ?
"MD5" :
645 (md == MBEDTLS_MD_SHA1) ?
"SHA1" :
646 (md == MBEDTLS_MD_SHA224) ?
"SHA224" :
647 (md == MBEDTLS_MD_RIPEMD160) ?
"RIPEMD160" :
648 (md == MBEDTLS_MD_SHA256) ?
"SHA256" :
649 (md == MBEDTLS_MD_SHA384) ?
"SHA384" :
650 (md == MBEDTLS_MD_SHA512) ?
"SHA512" :
651#if MBEDTLS_VERSION_NUMBER < 0x03000000
653 (md == MBEDTLS_MD_MD4) ?
"MD4" :
654 (md == MBEDTLS_MD_MD2) ?
"MD2" :
658 dStr_sprintfa(ds,
"This certificate's hash algorithm is not accepted "
667 const char *type_str = mbedtls_pk_get_name(&cert->pk);
669 dStr_sprintfa(ds,
"This certificate's public key algorithm is not accepted "
670 "(%s).\n", type_str);
678 int key_bits = mbedtls_pk_get_bitlen(&cert->pk);
679 const char *type_str = mbedtls_pk_get_name(&cert->pk);
681 dStr_sprintfa(ds,
"This certificate's key is not accepted, which generally "
682 "means it's too weak (%d-bit %s).\n", key_bits, type_str);
690 static const struct certerr {
692 void (*cert_err_fn)(
const mbedtls_x509_crt *cert,
Dstr *ds);
702 const uint_t ncert_errors =
sizeof(cert_error) /
sizeof(cert_error[0]);
707 for (u = 0; u < ncert_errors; u++) {
708 if (flags & cert_error[u].val) {
709 flags &= ~cert_error[u].val;
710 cert_error[u].cert_err_fn(cert, ds);
714 dStr_sprintfa(ds,
"Unknown certificate error(s): flag value 0x%04x",
723 const CertAuth_t *c1 = (CertAuth_t *)v1, *c2 = (CertAuth_t *)v2;
725 return strcmp(c1->name, c2->name);
730 const CertAuth_t *c = (CertAuth_t *)v1;
731 const char *name = (
char *)v2;
733 return strcmp(c->name, name);
742 const uint_t buflen = 512;
744 const mbedtls_x509_crt *last = cert;
749 mbedtls_x509_dn_gets(buf, buflen, &last->issuer);
754 ca =
dNew(CertAuth_t, 1);
769 const mbedtls_x509_crt *cert;
771 int choice = -1, ret = -1;
772 char *title =
dStrconcat(
"Dillo TLS security warning: ",srv->hostname,NULL);
774 cert = mbedtls_ssl_get_peer_cert(ssl);
778 "No certificate received from this site. Can't verify who it is.",
779 "Continue",
"Cancel", NULL);
787 st = mbedtls_ssl_get_verify_result(ssl);
792 Tls_print_cert_chain(cert);
797 }
else if (st == 0xFFFFFFFF) {
803 MSG_ERR(
"mbedtls_ssl_get_verify_result: result is not available");
812 dFree(dialog_warning_msg);
819 }
else if (choice == 1) {
855 mbedtls_ssl_close_notify(c->ssl);
856 mbedtls_ssl_free(c->ssl);
877 if (error_type == MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY)
879 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE)
880 errmsg =
"unexpected message received";
881 else if (error_type == MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC)
882 errmsg =
"record received with incorrect MAC";
883 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED) {
885 errmsg =
"decryption failed";
886 }
else if (error_type == MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW)
887 errmsg =
"\"A TLSCiphertext record was received that had a length more "
888 "than 2^14+2048 bytes, or a record decrypted to a TLSCompressed"
889 " record with more than 2^14+1024 bytes.\"";
890 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE)
891 errmsg =
"\"decompression function received improper input\"";
892 else if (error_type == MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE)
893 errmsg =
"\"sender was unable to negotiate an acceptable set of security"
894 " parameters given the options available\"";
895 else if (error_type == MBEDTLS_SSL_ALERT_MSG_NO_CERT)
896 errmsg =
"no cert (an obsolete alert last used in SSL3)";
897 else if (error_type == MBEDTLS_SSL_ALERT_MSG_BAD_CERT)
898 errmsg =
"bad certificate";
899 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT)
900 errmsg =
"certificate of unsupported type";
901 else if (error_type == MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED)
902 errmsg =
"certificate revoked by its signer";
903 else if (error_type == MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED)
904 errmsg =
"certificate expired or not currently valid";
905 else if (error_type == MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN)
906 errmsg =
"certificate error of an unknown sort";
907 else if (error_type == MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER)
908 errmsg =
"illegal parameter in handshake";
909 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA)
911 else if (error_type == MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED)
913 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR)
915 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR)
917 else if (error_type == MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION) {
919 errmsg =
"export restriction";
920 }
else if (error_type == MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION)
921 errmsg =
"protocol version is recognized but not supported";
922 else if (error_type == MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY)
923 errmsg =
"server requires ciphers more secure than those supported by "
925 else if (error_type == MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR)
926 errmsg =
"internal error (not the client's fault)";
927 else if (error_type == MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK)
928 errmsg =
"inappropriate fallback";
929 else if (error_type == MBEDTLS_SSL_ALERT_MSG_USER_CANCELED)
930 errmsg =
"\"handshake is being canceled for some reason unrelated to a "
931 "protocol failure\"";
932 else if (error_type == MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION)
933 errmsg =
"no renegotiation";
934 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT)
935 errmsg =
"unsupported ext";
936 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME)
937 errmsg =
"unrecognized name";
938 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY)
939 errmsg =
"unknown psk identity";
940 else if (error_type == MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL)
941 errmsg =
"no application protocol";
942 else errmsg =
"unknown alert value";
944 MSG_WARN(
"mbedtls_ssl_handshake() received TLS fatal alert %d (%s)\n",
959 MSG(
"Tls_connect: conn for fd %d not valid\n", fd);
963#if MBEDTLS_VERSION_NUMBER < 0x03000000
964 int ssl_state = conn->ssl->state;
966 int ssl_state = conn->ssl->MBEDTLS_PRIVATE(state);
968 if (ssl_state != MBEDTLS_SSL_HANDSHAKE_OVER) {
969 ret = mbedtls_ssl_handshake(conn->ssl);
971 if (ret == MBEDTLS_ERR_SSL_WANT_READ ||
972 ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
975 _MSG(
"iowatching fd %d for tls -- want %s\n", fd,
976 ret == MBEDTLS_ERR_SSL_WANT_READ ?
"read" :
"write");
981 }
else if (ret == 0) {
987 mbedtls_ssl_context *ssl = conn->ssl;
988 const char *version = mbedtls_ssl_get_version(ssl),
989 *cipher = mbedtls_ssl_get_ciphersuite(ssl);
994 MSG(
" %s, cipher %s\n", version, cipher);
1000 }
else if (ret == MBEDTLS_ERR_NET_SEND_FAILED) {
1001 MSG(
"mbedtls_ssl_handshake() send failed. Server may not be accepting"
1003 }
else if (ret == MBEDTLS_ERR_NET_CONNECT_FAILED) {
1004 MSG(
"mbedtls_ssl_handshake() connect failed.\n");
1005 }
else if (ret == MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) {
1011#if MBEDTLS_VERSION_NUMBER < 0x03000000
1016 }
else if (ret == MBEDTLS_ERR_SSL_INVALID_RECORD) {
1017 MSG(
"mbedtls_ssl_handshake() failed upon receiving 'an invalid "
1019 }
else if (ret == MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE) {
1020 MSG(
"mbedtls_ssl_handshake() failed: 'The requested feature is not "
1022#if MBEDTLS_VERSION_NUMBER < 0x03000000
1023 }
else if (ret == MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) {
1024 MSG(
"mbedtls_ssl_handshake() failed: 'Processing of the "
1025 "ServerKeyExchange handshake message failed.'\n");
1027 }
else if (ret == MBEDTLS_ERR_SSL_CONN_EOF) {
1028 MSG(
"mbedtls_ssl_handshake() failed: Read EOF. Connection closed by "
1031 MSG(
"mbedtls_ssl_handshake() failed with error -0x%04x\n", -ret);
1042 conn->connecting =
FALSE;
1049 MSG(
"Connection disappeared. Too long with a popup popped up?\n");
1064 mbedtls_ssl_context *ssl =
dNew0(mbedtls_ssl_context, 1);
1076 if (success && (ret = mbedtls_ssl_setup(ssl, &
ssl_conf))) {
1077 MSG(
"mbedtls_ssl_setup failed %d\n", ret);
1085 mbedtls_ssl_set_bio(ssl, &conn->fd, mbedtls_net_send, mbedtls_net_recv,
1089 if (success && (ret = mbedtls_ssl_set_hostname(ssl,
URL_HOST(url)))) {
1090 MSG(
"mbedtls_ssl_set_hostname failed %d\n", ret);
1107 Conn_t *c = (Conn_t*)conn;
1108 int ret = mbedtls_ssl_read(c->ssl, buf, len);
1111 if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
1114 }
else if (ret == MBEDTLS_ERR_SSL_WANT_READ) {
1117 }
else if (ret == MBEDTLS_ERR_NET_CONN_RESET) {
1118 MSG(
"READ failed: TLS connection reset by server.\n");
1120 MSG(
"READ failed with -0x%04x: an mbed tls error.\n", -ret);
1131 Conn_t *c = (Conn_t*)conn;
1132 int ret = mbedtls_ssl_write(c->ssl, buf, len);
1135 MSG(
"WRITE failed with -0x%04x: an mbed tls error\n", -ret);
1157 dStr_append(ds,
"TLS: Certificate chain roots during this session:\n");
1159 for (i = 0; i < ca_len; i++) {
1161 const int servers_len = ca->servers ?
dList_length(ca->servers) : 0;
1162 char *ca_name = strstr(ca->name,
"CN=");
1165 ca_name = strstr(ca->name,
"OU=");
1173 for (j = 0; j < servers_len; j++) {
1177 dStr_sprintfa(ds,
"%s%s%s", ipv6?
"[":
"", s->hostname, ipv6?
"]":
"");
1195 mbedtls_x509_crt_free(
cacerts.next);
1201 for (i = 0; i < n; i++) {
1218 for (i = 0; i < n; i++) {
1233 for (i = 0; i < n; i++) {
int a_Dialog_choice(const char *title, const char *msg,...)
Make a question-dialog with a question and alternatives.
char * dStrconcat(const char *s1,...)
Concatenate a NULL-terminated list of strings.
void dList_insert_sorted(Dlist *lp, void *data, dCompareFunc func)
Insert an element into a sorted list.
int dStrAsciiCasecmp(const char *s1, const char *s2)
void dStr_sprintfa(Dstr *ds, const char *format,...)
Printf-like function that appends.
void dStr_append(Dstr *ds, const char *s)
Append a C string to a Dstr.
char * dStrdup(const char *s)
Dlist * dList_new(int size)
Create a new empty list.
int dList_length(Dlist *lp)
For completing the ADT.
void * dList_nth_data(Dlist *lp, int n0)
Return the nth data item, NULL when not found or 'n0' is out of range.
void dList_remove_fast(Dlist *lp, const void *data)
Remove a data item without preserving order.
void dStr_free(Dstr *ds, int all)
Free a dillo string.
int dClose(int fd)
Close a FD handling EINTR.
void dStr_append_c(Dstr *ds, int c)
Append one character.
Dstr * dStr_new(const char *s)
Create a new string.
void dList_append(Dlist *lp, void *data)
Append a data item to the list.
void * dList_find_sorted(Dlist *lp, const void *data, dCompareFunc func)
Search a sorted list.
void dList_free(Dlist *lp)
Free a list (not its elements)
void * dList_find_custom(Dlist *lp, const void *data, dCompareFunc func)
Search a data item using a custom function.
char * dGethomedir(void)
Return the home directory in a static string (don't free)
#define dNew0(type, count)
#define dReturn_val_if_fail(expr, val)
#define dNew(type, count)
void errmsg(char *caller, char *called, int errornum, char *file, int line)
void a_Http_connect_done(int fd, bool_t success)
void a_IOwatch_add_fd(int fd, int when, Fl_FD_Handler Callback, void *usr_data=0)
Hook a Callback for a certain activities in a FD.
void a_IOwatch_remove_fd(int fd, int when)
Remove a Callback for a given FD (or just remove some events)
void a_Klist_remove(Klist_t *Klist, int Key)
Remove data by Key.
void * a_Klist_get_data(Klist_t *Klist, int Key)
Return the data pointer for a given Key (or NULL if not found)
int a_Klist_insert(Klist_t **Klist, void *Data)
Insert a data pointer and return a key for it.
DilloPrefs prefs
Global Data.
#define TLS_CONNECT_NEVER
#define TLS_CONNECT_READY
#define TLS_CONNECT_NOT_YET
static void Tls_cert_authorities_print_summary()
int a_Tls_mbedtls_certificate_is_clean(const DilloUrl *url)
static mbedtls_x509_crt cacerts
static void Tls_load_certificates_from_file(const char *const filename)
static void Tls_fd_map_remove_entry(int fd)
void * a_Tls_mbedtls_connection(int fd)
static void Tls_servers_freeall()
void a_Tls_mbedtls_init(void)
static void Tls_cert_bad_hash(const mbedtls_x509_crt *cert, Dstr *ds)
static int Tls_servers_cmp(const void *v1, const void *v2)
static Conn_t * Tls_conn_new(int fd, const DilloUrl *url, mbedtls_ssl_context *ssl)
static int Tls_cert_auth_cmp(const void *v1, const void *v2)
static void Tls_load_certificates_from_path(const char *const pathname)
static void Tls_handshake(int fd, int connkey)
void a_Tls_mbedtls_reset_server_state(const DilloUrl *url)
void a_Tls_mbedtls_freeall(void)
#define CERT_STATUS_USER_ACCEPTED
static void Tls_fd_map_add_entry(int fd, int connkey)
static void Tls_remove_psk_ciphersuites()
static int Tls_fd_map_cmp(const void *v1, const void *v2)
static void Tls_load_certificates()
static int Tls_user_said_no(const DilloUrl *url)
static void Tls_cert_expired(const mbedtls_x509_crt *cert, Dstr *ds)
void a_Tls_mbedtls_close_by_fd(int fd)
static void Tls_handshake_cb(int fd, void *vconnkey)
static void Tls_close_by_key(int connkey)
int a_Tls_mbedtls_write(void *conn, void *buf, size_t len)
static void Tls_fatal_error_msg(int error_type)
#define CERT_STATUS_RECEIVING
static void Tls_cert_cn_mismatch(const mbedtls_x509_crt *cert, Dstr *ds)
#define CERT_STATUS_CLEAN
static mbedtls_ctr_drbg_context ctr_drbg
static void Tls_cert_not_valid_yet(const mbedtls_x509_crt *cert, Dstr *ds)
static int Tls_servers_by_url_cmp(const void *v1, const void *v2)
static int Tls_cert_auth_cmp_by_name(const void *v1, const void *v2)
static mbedtls_ssl_config ssl_conf
int a_Tls_mbedtls_read(void *conn, void *buf, size_t len)
static void Tls_cert_bad_key(const mbedtls_x509_crt *cert, Dstr *ds)
static mbedtls_entropy_context entropy
static bool_t ssl_enabled
static void Tls_fd_map_remove_all()
int a_Tls_mbedtls_connect_ready(const DilloUrl *url)
static int Tls_cert_status(const DilloUrl *url)
static char * Tls_make_bad_cert_msg(const mbedtls_x509_crt *cert, uint32_t flags)
static Klist_t * conn_list
static void Tls_cert_trust_chain_failed(const mbedtls_x509_crt *cert, Dstr *ds)
static Dlist * cert_authorities
static int Tls_make_conn_key(Conn_t *conn)
void a_Tls_mbedtls_connect(int fd, const DilloUrl *url)
static void Tls_update_cert_authorities_data(const mbedtls_x509_crt *cert, Server_t *srv)
static void Tls_cert_authorities_freeall()
static void Tls_cert_bad_pk_alg(const mbedtls_x509_crt *cert, Dstr *ds)
static void Tls_remove_duplicate_certificates()
static int Tls_examine_certificate(mbedtls_ssl_context *ssl, Server_t *srv)
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
int a_Url_host_type(const char *host)
What type of host is this?
DilloUrl * a_Url_dup(const DilloUrl *ori)
Duplicate a Url structure.