This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
/** \file tls.c - collect common TLS functionality |
| 2 |
* \author Matthias Andree |
| 3 |
* \date 2006 |
| 4 |
*/ |
| 5 |
|
| 6 |
#include "fetchmail.h" |
| 7 |
|
| 8 |
#ifdef HAVE_STRINGS_H |
| 9 |
#include <strings.h> |
| 10 |
#endif |
| 11 |
|
| 12 |
/** return true if user allowed TLS */ |
| 13 |
int maybe_tls(struct query *ctl) { |
| 14 |
#ifdef SSL_ENABLE |
| 15 |
/* opportunistic or forced TLS */ |
| 16 |
return (!ctl->sslproto || !strcasecmp(ctl->sslproto,"tls1")) |
| 17 |
&& !ctl->use_ssl; |
| 18 |
#else |
| 19 |
(void)ctl; |
| 20 |
return 0; |
| 21 |
#endif |
| 22 |
} |
| 23 |
|
| 24 |
/** return true if user requires TLS, note though that this code must |
| 25 |
* always use a logical AND with maybe_tls(). */ |
| 26 |
int must_tls(struct query *ctl) { |
| 27 |
#ifdef SSL_ENABLE |
| 28 |
return maybe_tls(ctl) |
| 29 |
&& (ctl->sslfingerprint || ctl->sslcertck |
| 30 |
|| (ctl->sslproto && !strcasecmp(ctl->sslproto, "tls1"))); |
| 31 |
#else |
| 32 |
(void)ctl; |
| 33 |
return 0; |
| 34 |
#endif |
| 35 |
} |