File: tls.c

package info (click to toggle)
fetchmail 6.3.6-1etch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 6,344 kB
  • ctags: 3,617
  • sloc: ansic: 26,507; sh: 4,967; perl: 3,180; python: 1,920; yacc: 448; makefile: 331; lex: 277; awk: 124; lisp: 84; sed: 16
file content (33 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/** \file tls.c - collect common TLS functionality 
 * \author Matthias Andree
 * \year 2006
 */

#include "fetchmail.h"

#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif

/** return true if user allowed TLS */
int maybe_tls(struct query *ctl) {
#ifdef SSL_ENABLE
         /* opportunistic  or forced TLS */
    return (!ctl->sslproto || !strcasecmp(ctl->sslproto,"tls1"))
	&& !ctl->use_ssl;
#else
    return 0;
#endif
}

/** return true if user requires TLS, note though that this code must
 * always use a logical AND with maybe_tls(). */
int must_tls(struct query *ctl) {
#ifdef SSL_ENABLE
    return maybe_tls(ctl)
	&& (ctl->sslfingerprint || ctl->sslcertck
		|| (ctl->sslproto && !strcasecmp(ctl->sslproto, "tls1")));
#else
    return 0;
#endif
}