]> Pileus Git - ~andy/fetchmail/blob - starttls.c
Record POT regeneration date.
[~andy/fetchmail] / starttls.c
1 /** \file starttls.c - collect common TLS functionality
2  * \author Matthias Andree
3  * \date 2006
4  */
5
6 #include "fetchmail.h"
7
8 #include <string.h>
9
10 #ifdef HAVE_STRINGS_H
11 #include <strings.h>
12 #endif
13
14 /** return true if user allowed opportunistic STARTTLS/STLS */
15 int maybe_starttls(struct query *ctl) {
16 #ifdef SSL_ENABLE
17          /* opportunistic  or forced TLS */
18     return (!ctl->sslproto || strlen(ctl->sslproto))
19         && !ctl->use_ssl;
20 #else
21     (void)ctl;
22     return 0;
23 #endif
24 }
25
26 /** return true if user requires STARTTLS/STLS, note though that this
27  * code must always use a logical AND with maybe_tls(). */
28 int must_starttls(struct query *ctl) {
29 #ifdef SSL_ENABLE
30     return maybe_starttls(ctl)
31         && (ctl->sslfingerprint || ctl->sslcertck
32                 || (ctl->sslproto && ctl->sslproto[0]));
33 #else
34     (void)ctl;
35     return 0;
36 #endif
37 }