aboutsummaryrefslogtreecommitdiffstats
path: root/tls.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2006-11-26 10:11:39 +0000
committerMatthias Andree <matthias.andree@gmx.de>2006-11-26 10:11:39 +0000
commit250f0ed84ac892ea85654790cb83331dcbd8d44f (patch)
tree3dafcc1b4ad19134898eb3c917a9bc4773477a47 /tls.c
parent4f86b804ced0aaccc581393862b13ddcb077dd2c (diff)
downloadfetchmail-250f0ed84ac892ea85654790cb83331dcbd8d44f.tar.gz
fetchmail-250f0ed84ac892ea85654790cb83331dcbd8d44f.tar.bz2
fetchmail-250f0ed84ac892ea85654790cb83331dcbd8d44f.zip
First step towards really fixing TLS vuln, CVE-2006-5867, still incomplete.
svn path=/branches/BRANCH_6-3/; revision=4962
Diffstat (limited to 'tls.c')
-rw-r--r--tls.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tls.c b/tls.c
new file mode 100644
index 00000000..2a1fee3e
--- /dev/null
+++ b/tls.c
@@ -0,0 +1,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
+}