Handling of GnuTLS encryption. More...
#include "config.h"#include <gnutls/gnutls.h>#include <gnutls/x509.h>#include <stdbool.h>#include <stdio.h>#include <string.h>#include <sys/stat.h>#include <time.h>#include "private.h"#include "mutt/lib.h"#include "config/lib.h"#include "core/lib.h"#include "lib.h"#include "connaccount.h"#include "connection.h"#include "globals.h"#include "muttlib.h"#include "ssl.h"
Include dependency graph for gnutls.c:Go to the source code of this file.
Data Structures | |
| struct | TlsSockData |
| TLS socket data -. More... | |
Macros | |
| #define | CERTERR_VALID 0 |
| #define | CERTERR_EXPIRED (1 << 0) |
| #define | CERTERR_NOTYETVALID (1 << 1) |
| #define | CERTERR_REVOKED (1 << 2) |
| #define | CERTERR_NOTTRUSTED (1 << 3) |
| #define | CERTERR_HOSTNAME (1 << 4) |
| #define | CERTERR_SIGNERNOTCA (1 << 5) |
| #define | CERTERR_INSECUREALG (1 << 6) |
| #define | CERTERR_OTHER (1 << 7) |
| #define | CERT_SEP "-----BEGIN" |
Functions | |
| int | gnutls_protocol_set_priority (gnutls_session_t session, const int *list) |
| static int | tls_init (void) |
| Set up Gnu TLS. | |
| static int | tls_verify_peers (gnutls_session_t tlsstate, gnutls_certificate_status_t *certstat) |
| Wrapper for gnutls_certificate_verify_peers() | |
| static void | tls_fingerprint (gnutls_digest_algorithm_t algo, struct Buffer *buf, const gnutls_datum_t *data) |
| Create a fingerprint of a TLS Certificate. | |
| static bool | tls_check_stored_hostname (const gnutls_datum_t *cert, const char *hostname) |
| Does the hostname match a stored certificate? | |
| static bool | tls_compare_certificates (const gnutls_datum_t *peercert) |
Compare certificates against $certificate_file | |
| static int | tls_check_preauth (const gnutls_datum_t *certdata, gnutls_certificate_status_t certstat, const char *hostname, int chainidx, int *certerr, int *savedcert) |
| Prepare a certificate for authentication. | |
| static void | add_cert (const char *title, gnutls_x509_crt_t cert, bool issuer, struct StringArray *carr) |
| Look up certificate info and save it to a list. | |
| static int | tls_check_one_certificate (const gnutls_datum_t *certdata, gnutls_certificate_status_t certstat, const char *hostname, int idx, size_t len) |
| Check a GnuTLS certificate. | |
| static int | tls_check_certificate (struct Connection *conn) |
| Check a connection's certificate. | |
| static void | tls_get_client_cert (struct Connection *conn) |
| Get the client certificate for a TLS connection. | |
| static int | tls_set_priority (struct TlsSockData *data) |
| Set the priority of various protocols. | |
| static int | tls_negotiate (struct Connection *conn) |
| Negotiate TLS connection. | |
| static int | tls_socket_poll (struct Connection *conn, time_t wait_secs) |
| Check if any data is waiting on a socket - Implements Connection::poll() -. | |
| static int | tls_socket_close (struct Connection *conn) |
| Close a TLS socket - Implements Connection::close() -. | |
| static int | tls_socket_open (struct Connection *conn) |
| Open a TLS socket - Implements Connection::open() -. | |
| static int | tls_socket_read (struct Connection *conn, char *buf, size_t count) |
| Read data from a TLS socket - Implements Connection::read() -. | |
| static int | tls_socket_write (struct Connection *conn, const char *buf, size_t count) |
| Write data to a TLS socket - Implements Connection::write() -. | |
| static int | tls_starttls_close (struct Connection *conn) |
| Close a TLS connection - Implements Connection::close() -. | |
| int | mutt_ssl_socket_setup (struct Connection *conn) |
| Set up SSL socket mulitplexor. | |
| int | mutt_ssl_starttls (struct Connection *conn) |
| Negotiate TLS over an already opened connection. | |
Variables | |
| static int | ProtocolPriority [] = { GNUTLS_TLS1_2, GNUTLS_TLS1_1, GNUTLS_TLS1, GNUTLS_SSL3, 0 } |
| This array needs to be large enough to hold all the possible values support by NeoMutt. | |
Handling of GnuTLS encryption.
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 gnutls.c.
| int gnutls_protocol_set_priority | ( | gnutls_session_t | session, |
| const int * | list ) |
Here is the caller graph for this function:
|
static |
Set up Gnu TLS.
| 0 | Success |
| -1 | Error |
Definition at line 92 of file gnutls.c.
Here is the caller graph for this function:
|
static |
Wrapper for gnutls_certificate_verify_peers()
| tlsstate | TLS state |
| certstat | Certificate state, e.g. GNUTLS_CERT_INVALID |
| 0 | Success If certstat was set. note: this does not mean success |
| >0 | Error |
Wrapper with sanity-checking.
certstat is technically a bitwise-or of gnutls_certificate_status_t values.
Definition at line 122 of file gnutls.c.
Here is the caller graph for this function:
|
static |
Create a fingerprint of a TLS Certificate.
| algo | Fingerprint algorithm, e.g. GNUTLS_MAC_SHA256 |
| buf | Buffer for the fingerprint |
| data | Certificate |
Definition at line 159 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Does the hostname match a stored certificate?
| cert | Certificate |
| hostname | Hostname |
| true | Hostname match found |
| false | Error, or no match |
Definition at line 188 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Compare certificates against $certificate_file
| peercert | Certificate |
| true | Certificate matches file |
| false | Error, or no match |
Definition at line 235 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Prepare a certificate for authentication.
| [in] | certdata | List of GnuTLS certificates |
| [in] | certstat | GnuTLS certificate status |
| [in] | hostname | Hostname |
| [in] | chainidx | Index in the certificate chain |
| [out] | certerr | Result, e.g. CERTERR_VALID |
| [out] | savedcert | 1 if certificate has been saved |
| 0 | Success |
| -1 | Error |
Definition at line 315 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Look up certificate info and save it to a list.
| title | Title for this block of certificate info |
| cert | Certificate |
| issuer | If true, look up the issuer rather than owner details |
| carr | Array to save info to |
Definition at line 427 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Check a GnuTLS certificate.
| certdata | List of GnuTLS certificates |
| certstat | GnuTLS certificate status |
| hostname | Hostname |
| idx | Index into certificate list |
| len | Length of certificate list |
| 1 | Success |
| 0 | Failure |
Definition at line 472 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Check a connection's certificate.
| conn | Connection to a server |
| 1 | Certificate is valid |
| 0 | Error, or certificate is invalid |
Definition at line 622 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get the client certificate for a TLS connection.
| conn | Connection to a server |
Definition at line 706 of file gnutls.c.
Here is the caller graph for this function:
|
static |
Set the priority of various protocols.
| data | TLS socket data |
| 0 | Success |
| -1 | Error |
Definition at line 829 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Negotiate TLS connection.
| conn | Connection to a server |
| 0 | Success |
| -1 | Error |
After TLS session has been initialized, attempt to negotiate TLS over the wire, including certificate checks.
Definition at line 876 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int mutt_ssl_socket_setup | ( | struct Connection * | conn | ) |
Set up SSL socket mulitplexor.
| conn | Connection to a server |
| 0 | Success |
| -1 | Error |
Definition at line 1129 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int mutt_ssl_starttls | ( | struct Connection * | conn | ) |
Negotiate TLS over an already opened connection.
| conn | Connection to a server |
| 0 | Success |
| -1 | Error |
Definition at line 1149 of file gnutls.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
This array needs to be large enough to hold all the possible values support by NeoMutt.
The initialized values are just placeholders–the array gets overwrriten in tls_negotiate() depending on the $ssl_use_* options.
Note: gnutls_protocol_set_priority() was removed in GnuTLS version 3.4 (2015-04). TLS 1.3 support wasn't added until version 3.6.5. Therefore, no attempt is made to support $ssl_use_tlsv1_3 in this code.
Definition at line 75 of file gnutls.c.