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);
361 mbedtls_version_get_string(ver);
363 int k = snprintf(buf, n,
"mbedTLS/%s", ver);
376 mbedtls_version_get_string_full(version);
377 MSG(
"TLS library: %s\n", version);
389 static const mbedtls_x509_crt_profile prof = {
390 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ) |
391 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) |
392 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ) |
393 MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA512 ),
401 mbedtls_ssl_config_defaults(&
ssl_conf, MBEDTLS_SSL_IS_CLIENT,
402 MBEDTLS_SSL_TRANSPORT_STREAM,
403 MBEDTLS_SSL_PRESET_DEFAULT);
404 mbedtls_ssl_conf_cert_profile(&
ssl_conf, &prof);
411#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
412 mbedtls_ssl_conf_max_tls_version(&
ssl_conf, MBEDTLS_SSL_VERSION_TLS1_2);
419 mbedtls_ssl_conf_session_tickets(&
ssl_conf,
420 MBEDTLS_SSL_SESSION_TICKETS_DISABLED);
424 mbedtls_x509_crt_init(&
cacerts);
427 mbedtls_entropy_init(&
entropy);
429 if((ret = mbedtls_ctr_drbg_seed(&
ctr_drbg, mbedtls_entropy_func, &
entropy,
430 (
unsigned char*)
"dillo tls", 9))) {
432 MSG_ERR(
"tls: mbedtls_ctr_drbg_seed() failed. TLS disabled.\n");
436 mbedtls_ssl_conf_authmode(&
ssl_conf, MBEDTLS_SSL_VERIFY_OPTIONAL);
452 const Server_t *s1 = (
const Server_t *)v1, *s2 = (
const Server_t *)v2;
456 cmp = s1->port - s2->port;
464 const Server_t *s = (
const Server_t *)v1;
497 s =
dNew(Server_t, 1);
536static void Tls_print_cert_chain(
const mbedtls_x509_crt *cert)
539 const mbedtls_x509_crt *last_cert;
540 const uint_t buflen = 2048;
546 if (cert->sig_md == MBEDTLS_MD_SHA1) {
547 MSG_WARN(
"In 2015, browsers have begun to deprecate SHA1 "
551 if (mbedtls_oid_get_sig_alg_desc(&cert->sig_oid, &sigalg))
554 key_bits = mbedtls_pk_get_bitlen(&cert->pk);
555 mbedtls_x509_dn_gets(buf, buflen, &cert->subject);
556 MSG(
"%d-bit %s: %s\n", key_bits, sigalg, buf);
562 mbedtls_x509_dn_gets(buf, buflen, &last_cert->issuer);
563 MSG(
"root: %s\n", buf);
573 const mbedtls_x509_time *date = &cert->valid_to;
575 dStr_sprintfa(ds,
"Certificate expired at: %04d/%02d/%02d %02d:%02d:%02d.\n",
576 date->year, date->mon, date->day, date->hour, date->min,
585 const uint_t buflen = 2048;
586 char cert_info_buf[buflen];
589 dStr_append(ds,
"This host is not one of the hostnames listed on the TLS "
590 "certificate that it sent");
602 mbedtls_x509_crt_info(cert_info_buf, buflen,
"", cert);
604 if ((san = strstr(cert_info_buf,
"subject alt name : "))) {
606 s = strchr(san,
'\n');
620 const uint_t buflen = 2048;
625 mbedtls_x509_dn_gets(buf, buflen, &cert->issuer);
627 dStr_sprintfa(ds,
"Couldn't reach any trusted root certificate from "
628 "supplied certificate. The issuer at the end of the "
629 "chain was: \"%s\"\n", buf);
637 const mbedtls_x509_time *date = &cert->valid_to;
639 dStr_sprintfa(ds,
"Certificate validity begins in the future at: "
640 "%04d/%02d/%02d %02d:%02d:%02d.\n",
641 date->year, date->mon, date->day, date->hour, date->min,
650#if MBEDTLS_VERSION_NUMBER < 0x03000000
651 mbedtls_md_type_t md = cert->sig_md;
653 mbedtls_md_type_t md = cert->MBEDTLS_PRIVATE(sig_md);
655 const char *hash = (md == MBEDTLS_MD_MD5) ?
"MD5" :
656 (md == MBEDTLS_MD_SHA1) ?
"SHA1" :
657 (md == MBEDTLS_MD_SHA224) ?
"SHA224" :
658 (md == MBEDTLS_MD_RIPEMD160) ?
"RIPEMD160" :
659 (md == MBEDTLS_MD_SHA256) ?
"SHA256" :
660 (md == MBEDTLS_MD_SHA384) ?
"SHA384" :
661 (md == MBEDTLS_MD_SHA512) ?
"SHA512" :
662#if MBEDTLS_VERSION_NUMBER < 0x03000000
664 (md == MBEDTLS_MD_MD4) ?
"MD4" :
665 (md == MBEDTLS_MD_MD2) ?
"MD2" :
669 dStr_sprintfa(ds,
"This certificate's hash algorithm is not accepted "
678 const char *type_str = mbedtls_pk_get_name(&cert->pk);
680 dStr_sprintfa(ds,
"This certificate's public key algorithm is not accepted "
681 "(%s).\n", type_str);
689 int key_bits = mbedtls_pk_get_bitlen(&cert->pk);
690 const char *type_str = mbedtls_pk_get_name(&cert->pk);
692 dStr_sprintfa(ds,
"This certificate's key is not accepted, which generally "
693 "means it's too weak (%d-bit %s).\n", key_bits, type_str);
701 static const struct certerr {
703 void (*cert_err_fn)(
const mbedtls_x509_crt *cert,
Dstr *ds);
713 const uint_t ncert_errors =
sizeof(cert_error) /
sizeof(cert_error[0]);
718 for (u = 0; u < ncert_errors; u++) {
719 if (flags & cert_error[u].val) {
720 flags &= ~cert_error[u].val;
721 cert_error[u].cert_err_fn(cert, ds);
725 dStr_sprintfa(ds,
"Unknown certificate error(s): flag value 0x%04x",
734 const CertAuth_t *c1 = (CertAuth_t *)v1, *c2 = (CertAuth_t *)v2;
736 return strcmp(c1->name, c2->name);
741 const CertAuth_t *c = (CertAuth_t *)v1;
742 const char *name = (
char *)v2;
744 return strcmp(c->name, name);
753 const uint_t buflen = 512;
755 const mbedtls_x509_crt *last = cert;
760 mbedtls_x509_dn_gets(buf, buflen, &last->issuer);
765 ca =
dNew(CertAuth_t, 1);
780 const mbedtls_x509_crt *cert;
782 int choice = -1, ret = -1;
783 char *title =
dStrconcat(
"Dillo TLS security warning: ",srv->hostname,NULL);
785 cert = mbedtls_ssl_get_peer_cert(ssl);
789 "No certificate received from this site. Can't verify who it is.",
790 "Continue",
"Cancel", NULL);
798 st = mbedtls_ssl_get_verify_result(ssl);
803 Tls_print_cert_chain(cert);
808 }
else if (st == 0xFFFFFFFF) {
814 MSG_ERR(
"mbedtls_ssl_get_verify_result: result is not available");
823 dFree(dialog_warning_msg);
830 }
else if (choice == 1) {
866 mbedtls_ssl_close_notify(c->ssl);
867 mbedtls_ssl_free(c->ssl);
888 if (error_type == MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY)
890 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE)
891 errmsg =
"unexpected message received";
892 else if (error_type == MBEDTLS_SSL_ALERT_MSG_BAD_RECORD_MAC)
893 errmsg =
"record received with incorrect MAC";
894 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECRYPTION_FAILED) {
896 errmsg =
"decryption failed";
897 }
else if (error_type == MBEDTLS_SSL_ALERT_MSG_RECORD_OVERFLOW)
898 errmsg =
"\"A TLSCiphertext record was received that had a length more "
899 "than 2^14+2048 bytes, or a record decrypted to a TLSCompressed"
900 " record with more than 2^14+1024 bytes.\"";
901 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECOMPRESSION_FAILURE)
902 errmsg =
"\"decompression function received improper input\"";
903 else if (error_type == MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE)
904 errmsg =
"\"sender was unable to negotiate an acceptable set of security"
905 " parameters given the options available\"";
906 else if (error_type == MBEDTLS_SSL_ALERT_MSG_NO_CERT)
907 errmsg =
"no cert (an obsolete alert last used in SSL3)";
908 else if (error_type == MBEDTLS_SSL_ALERT_MSG_BAD_CERT)
909 errmsg =
"bad certificate";
910 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT)
911 errmsg =
"certificate of unsupported type";
912 else if (error_type == MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED)
913 errmsg =
"certificate revoked by its signer";
914 else if (error_type == MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED)
915 errmsg =
"certificate expired or not currently valid";
916 else if (error_type == MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN)
917 errmsg =
"certificate error of an unknown sort";
918 else if (error_type == MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER)
919 errmsg =
"illegal parameter in handshake";
920 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA)
922 else if (error_type == MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED)
924 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR)
926 else if (error_type == MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR)
928 else if (error_type == MBEDTLS_SSL_ALERT_MSG_EXPORT_RESTRICTION) {
930 errmsg =
"export restriction";
931 }
else if (error_type == MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION)
932 errmsg =
"protocol version is recognized but not supported";
933 else if (error_type == MBEDTLS_SSL_ALERT_MSG_INSUFFICIENT_SECURITY)
934 errmsg =
"server requires ciphers more secure than those supported by "
936 else if (error_type == MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR)
937 errmsg =
"internal error (not the client's fault)";
938 else if (error_type == MBEDTLS_SSL_ALERT_MSG_INAPROPRIATE_FALLBACK)
939 errmsg =
"inappropriate fallback";
940 else if (error_type == MBEDTLS_SSL_ALERT_MSG_USER_CANCELED)
941 errmsg =
"\"handshake is being canceled for some reason unrelated to a "
942 "protocol failure\"";
943 else if (error_type == MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION)
944 errmsg =
"no renegotiation";
945 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT)
946 errmsg =
"unsupported ext";
947 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNRECOGNIZED_NAME)
948 errmsg =
"unrecognized name";
949 else if (error_type == MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY)
950 errmsg =
"unknown psk identity";
951 else if (error_type == MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL)
952 errmsg =
"no application protocol";
953 else errmsg =
"unknown alert value";
955 MSG_WARN(
"mbedtls_ssl_handshake() received TLS fatal alert %d (%s)\n",
970 MSG(
"Tls_connect: conn for fd %d not valid\n", fd);
974#if MBEDTLS_VERSION_NUMBER < 0x03000000
975 int ssl_state = conn->ssl->state;
977 int ssl_state = conn->ssl->MBEDTLS_PRIVATE(state);
979 if (ssl_state != MBEDTLS_SSL_HANDSHAKE_OVER) {
980 ret = mbedtls_ssl_handshake(conn->ssl);
982 if (ret == MBEDTLS_ERR_SSL_WANT_READ ||
983 ret == MBEDTLS_ERR_SSL_WANT_WRITE) {
986 _MSG(
"iowatching fd %d for tls -- want %s\n", fd,
987 ret == MBEDTLS_ERR_SSL_WANT_READ ?
"read" :
"write");
992 }
else if (ret == 0) {
998 mbedtls_ssl_context *ssl = conn->ssl;
999 const char *version = mbedtls_ssl_get_version(ssl),
1000 *cipher = mbedtls_ssl_get_ciphersuite(ssl);
1005 MSG(
" %s, cipher %s\n", version, cipher);
1011 }
else if (ret == MBEDTLS_ERR_NET_SEND_FAILED) {
1012 MSG(
"mbedtls_ssl_handshake() send failed. Server may not be accepting"
1014 }
else if (ret == MBEDTLS_ERR_NET_CONNECT_FAILED) {
1015 MSG(
"mbedtls_ssl_handshake() connect failed.\n");
1016 }
else if (ret == MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) {
1022#if MBEDTLS_VERSION_NUMBER < 0x03000000
1027 }
else if (ret == MBEDTLS_ERR_SSL_INVALID_RECORD) {
1028 MSG(
"mbedtls_ssl_handshake() failed upon receiving 'an invalid "
1030 }
else if (ret == MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE) {
1031 MSG(
"mbedtls_ssl_handshake() failed: 'The requested feature is not "
1033#if MBEDTLS_VERSION_NUMBER < 0x03000000
1034 }
else if (ret == MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) {
1035 MSG(
"mbedtls_ssl_handshake() failed: 'Processing of the "
1036 "ServerKeyExchange handshake message failed.'\n");
1038 }
else if (ret == MBEDTLS_ERR_SSL_CONN_EOF) {
1039 MSG(
"mbedtls_ssl_handshake() failed: Read EOF. Connection closed by "
1042 MSG(
"mbedtls_ssl_handshake() failed with error -0x%04x\n", -ret);
1053 conn->connecting =
FALSE;
1060 MSG(
"Connection disappeared. Too long with a popup popped up?\n");
1075 mbedtls_ssl_context *ssl =
dNew0(mbedtls_ssl_context, 1);
1087 if (success && (ret = mbedtls_ssl_setup(ssl, &
ssl_conf))) {
1088 MSG(
"mbedtls_ssl_setup failed %d\n", ret);
1096 mbedtls_ssl_set_bio(ssl, &conn->fd, mbedtls_net_send, mbedtls_net_recv,
1100 if (success && (ret = mbedtls_ssl_set_hostname(ssl,
URL_HOST(url)))) {
1101 MSG(
"mbedtls_ssl_set_hostname failed %d\n", ret);
1118 Conn_t *c = (Conn_t*)conn;
1119 int ret = mbedtls_ssl_read(c->ssl, buf, len);
1122 if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
1125 }
else if (ret == MBEDTLS_ERR_SSL_WANT_READ) {
1128 }
else if (ret == MBEDTLS_ERR_NET_CONN_RESET) {
1129 MSG(
"READ failed: TLS connection reset by server.\n");
1131 MSG(
"READ failed with -0x%04x: an mbed tls error.\n", -ret);
1142 Conn_t *c = (Conn_t*)conn;
1143 int ret = mbedtls_ssl_write(c->ssl, buf, len);
1146 MSG(
"WRITE failed with -0x%04x: an mbed tls error\n", -ret);
1168 dStr_append(ds,
"TLS: Certificate chain roots during this session:\n");
1170 for (i = 0; i < ca_len; i++) {
1172 const int servers_len = ca->servers ?
dList_length(ca->servers) : 0;
1173 char *ca_name = strstr(ca->name,
"CN=");
1176 ca_name = strstr(ca->name,
"OU=");
1184 for (j = 0; j < servers_len; j++) {
1188 dStr_sprintfa(ds,
"%s%s%s", ipv6?
"[":
"", s->hostname, ipv6?
"]":
"");
1206 mbedtls_x509_crt_free(
cacerts.next);
1212 for (i = 0; i < n; i++) {
1229 for (i = 0; i < n; i++) {
1244 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
const char * a_Tls_mbedtls_version(char *buf, int n)
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.