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"Go to the source code of this file.
Data Structures | |
| struct | TlsSockData |
| This array needs to be large enough to hold all the possible values support by NeoMutt. More... | |
Macros | |
| #define | CERTERR_VALID 0 |
| Certificate is valid. | |
| #define | CERTERR_EXPIRED (1 << 0) |
| Certificate is expired. | |
| #define | CERTERR_NOTYETVALID (1 << 1) |
| Certificate is not yet valid. | |
| #define | CERTERR_REVOKED (1 << 2) |
| Certificate has been revoked. | |
| #define | CERTERR_NOTTRUSTED (1 << 3) |
| Certificate issuer is not trusted. | |
| #define | CERTERR_HOSTNAME (1 << 4) |
| Certificate hostname does not match. | |
| #define | CERTERR_SIGNERNOTCA (1 << 5) |
| Certificate signer is not a CA. | |
| #define | CERTERR_INSECUREALG (1 << 6) |
| Certificate uses insecure algorithm. | |
| #define | CERTERR_OTHER (1 << 7) |
| Other certificate error. | |
| #define | CERT_SEP "-----BEGIN" |
| Certificate separator string. | |
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 bool | tls_socket_poll_with_timeout (struct Connection *conn) |
| Poll a socket with configured timeout. | |
| 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. | |
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.
| #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) |
| int gnutls_protocol_set_priority | ( | gnutls_session_t | session, |
| const int * | list ) |
|
static |
Set up Gnu TLS.
| 0 | Success |
| -1 | Error |
Definition at line 92 of file gnutls.c.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
static |
Check a connection's certificate.
| conn | Connection to a server |
| 1 | Certificate is valid |
| 0 | Error, or certificate is invalid |
Definition at line 627 of file gnutls.c.
|
static |
Get the client certificate for a TLS connection.
| conn | Connection to a server |
Definition at line 713 of file gnutls.c.
|
static |
Set the priority of various protocols.
| data | TLS socket data |
| 0 | Success |
| -1 | Error |
Definition at line 823 of file gnutls.c.
|
static |
Poll a socket with configured timeout.
| conn | Connection to poll |
| true | Socket is ready |
| false | Timeout or error occurred |
Definition at line 859 of file gnutls.c.
|
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 884 of file gnutls.c.
| 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 1156 of file gnutls.c.
| 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 1176 of file gnutls.c.