NeoMutt  2020-08-07-1-gab41a1
Teaching an old dog new tricks
DOXYGEN
ssl.h File Reference

Handling of SSL encryption. More...

#include "config.h"
#include <stdbool.h>
+ Include dependency graph for ssl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mutt_ssl_socket_setup (struct Connection *conn)
 Set up SSL socket mulitplexor. More...
 
int dlg_verify_certificate (const char *title, struct ListHead *list, bool allow_always, bool allow_skip)
 Ask the user to validate the certificate. More...
 

Detailed Description

Handling of SSL encryption.

Authors
  • Tommi Komulainen

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file ssl.h.

Function Documentation

◆ mutt_ssl_socket_setup()

int mutt_ssl_socket_setup ( struct Connection conn)

Set up SSL socket mulitplexor.

Parameters
connConnection to a server
Return values
0Success
-1Error

Definition at line 1116 of file gnutls.c.

1117 {
1118  if (tls_init() < 0)
1119  return -1;
1120 
1121  conn->open = tls_socket_open;
1122  conn->read = tls_socket_read;
1123  conn->write = tls_socket_write;
1124  conn->close = tls_socket_close;
1125  conn->poll = tls_socket_poll;
1126 
1127  return 0;
1128 }
int(* read)(struct Connection *conn, char *buf, size_t count)
Read from a socket Connection.
Definition: connection.h:72
static int tls_socket_write(struct Connection *conn, const char *buf, size_t count)
Write data to a TLS socket - Implements Connection::write()
Definition: gnutls.c:1063
static int tls_socket_read(struct Connection *conn, char *buf, size_t count)
Read data from a TLS socket - Implements Connection::read()
Definition: gnutls.c:1036
int(* open)(struct Connection *conn)
Note about ssf: in actuality, NeoMutt uses this as a boolean to determine if the connection is "secur...
Definition: connection.h:62
static int tls_socket_poll(struct Connection *conn, time_t wait_secs)
Check whether a socket read would block - Implements Connection::poll()
Definition: gnutls.c:979
int(* close)(struct Connection *conn)
Close a socket Connection.
Definition: connection.h:100
static int tls_socket_open(struct Connection *conn)
Open a TLS socket - Implements Connection::open()
Definition: gnutls.c:1019
static int tls_init(void)
Set up Gnu TLS.
Definition: gnutls.c:89
int(* poll)(struct Connection *conn, time_t wait_secs)
Check whether a socket read would block.
Definition: connection.h:92
int(* write)(struct Connection *conn, const char *buf, size_t count)
Write to a socket Connection.
Definition: connection.h:82
static int tls_socket_close(struct Connection *conn)
Close a TLS socket - Implements Connection::close()
Definition: gnutls.c:994
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_verify_certificate()

int dlg_verify_certificate ( const char *  title,
struct ListHead *  list,
bool  allow_always,
bool  allow_skip 
)

Ask the user to validate the certificate.

Parameters
titleMenu title
listCertificate text to display
allow_alwaysIf true, allow the user to always accept the certificate
allow_skipIf true, allow the user to skip the verification
Return values
1Reject certificate (or menu aborted)
2Accept certificate once
3Accept certificate always/skip (see notes)
4Accept certificate skip

The possible retvals will depend on the parameters. The options are given in the order: Reject, Once, Always, Skip. The retval represents the chosen option.

Definition at line 69 of file dlgverifycert.c.

71 {
72  struct Menu *menu = mutt_menu_new(MENU_GENERIC);
74  dlg->help_data = VerifyHelp;
75  dlg->help_menu = MENU_GENERIC;
76 
78 
79  struct ListNode *np = NULL;
80  STAILQ_FOREACH(np, list, entries)
81  {
83  }
84 
85  menu->title = title;
86 
87  if (allow_always)
88  {
89  if (allow_skip)
90  {
91  menu->prompt = _("(r)eject, accept (o)nce, (a)ccept always, (s)kip");
92  /* L10N: The letters correspond to the choices in the string:
93  "(r)eject, accept (o)nce, (a)ccept always, (s)kip"
94  This is an interactive certificate confirmation prompt for an SSL connection. */
95  menu->keys = _("roas");
96  }
97  else
98  {
99  menu->prompt = _("(r)eject, accept (o)nce, (a)ccept always");
100  /* L10N: The letters correspond to the choices in the string:
101  "(r)eject, accept (o)nce, (a)ccept always"
102  This is an interactive certificate confirmation prompt for an SSL connection. */
103  menu->keys = _("roa");
104  }
105  }
106  else
107  {
108  if (allow_skip)
109  {
110  menu->prompt = _("(r)eject, accept (o)nce, (s)kip");
111  /* L10N: The letters correspond to the choices in the string:
112  "(r)eject, accept (o)nce, (s)kip"
113  This is an interactive certificate confirmation prompt for an SSL connection. */
114  menu->keys = _("ros");
115  }
116  else
117  {
118  menu->prompt = _("(r)eject, accept (o)nce");
119  /* L10N: The letters correspond to the choices in the string:
120  "(r)eject, accept (o)nce"
121  This is an interactive certificate confirmation prompt for an SSL connection. */
122  menu->keys = _("ro");
123  }
124  }
125 
126  bool old_ime = OptIgnoreMacroEvents;
127  OptIgnoreMacroEvents = true;
128 
129  int rc = 0;
130  while (rc == 0)
131  {
132  switch (mutt_menu_loop(menu))
133  {
134  case -1: // Abort: Ctrl-G
135  case OP_EXIT: // Q)uit
136  case OP_MAX + 1: // R)eject
137  rc = 1;
138  break;
139  case OP_MAX + 2: // O)nce
140  rc = 2;
141  break;
142  case OP_MAX + 3: // A)lways / S)kip
143  rc = 3;
144  break;
145  case OP_MAX + 4: // S)kip
146  rc = 4;
147  break;
148  }
149  }
150  OptIgnoreMacroEvents = old_ime;
151 
152  mutt_menu_pop_current(menu);
153  mutt_menu_free(&menu);
155 
156  return rc;
157 }
#define NONULL(x)
Definition: string2.h:37
GUI selectable list of items.
Definition: mutt_menu.h:55
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
char * prompt
Prompt for user, similar to mutt_multi_choice.
Definition: mutt_menu.h:75
#define _(a)
Definition: message.h:28
WHERE bool OptIgnoreMacroEvents
(pseudo) don&#39;t process macro/push/exec events while set
Definition: options.h:38
A division of the screen.
Definition: mutt_window.h:115
struct MuttWindow * dialog_create_simple_index(struct Menu *menu, enum WindowType type)
Create a simple index Dialog.
Definition: dialog.c:165
const char * title
Title of this menu.
Definition: mutt_menu.h:57
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
void dialog_destroy_simple_index(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: dialog.c:209
static const struct Mapping VerifyHelp[]
Help Bar for the Certificate Verification dialog.
Definition: dlgverifycert.c:44
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
char * keys
Keys used in the prompt.
Definition: mutt_menu.h:76
char * data
String.
Definition: list.h:36
A List node for strings.
Definition: list.h:34
Certificate Dialog, dlg_verify_certificate()
Definition: mutt_window.h:78
Generic selection list.
Definition: keymap.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function: