diff --git a/fetchmail-6.3.8-smtp_errors.patch b/fetchmail-6.3.8-smtp_errors.patch
index ce7ecc9..3985dcb 100644
--- a/fetchmail-6.3.8-smtp_errors.patch
+++ b/fetchmail-6.3.8-smtp_errors.patch
@@ -10,7 +10,7 @@ Index: fetchmail-6.3.10-beta1/sink.c
===================================================================
--- fetchmail-6.3.10-beta1.orig/sink.c 2009-05-25 17:55:07.000000000 +0200
+++ fetchmail-6.3.10-beta1/sink.c 2009-06-01 14:37:12.000000000 +0200
-@@ -551,6 +551,19 @@ static int handle_smtp_report(struct que
+@@ -553,6 +553,19 @@ static int handle_smtp_report(struct que
free(responses[0]);
return(PS_TRANSIENT);
@@ -30,7 +30,7 @@ Index: fetchmail-6.3.10-beta1/sink.c
default:
/* bounce non-transient errors back to the sender */
if (smtperr >= 500 && smtperr <= 599)
-@@ -620,7 +633,7 @@ static int handle_smtp_report_without_bo
+@@ -622,7 +635,7 @@ static int handle_smtp_report_without_bo
#endif /* __DONT_FEED_THE_SPAMMERS__ */
return(PS_REFUSED);
diff --git a/fetchmail-openssl11.patch b/fetchmail-openssl11.patch
index 3077b2f..9e01412 100644
--- a/fetchmail-openssl11.patch
+++ b/fetchmail-openssl11.patch
@@ -1,14 +1,1576 @@
-Index: fetchmail-6.3.26/socket.c
-===================================================================
---- fetchmail-6.3.26.orig/socket.c 2013-04-23 22:00:45.000000000 +0200
-+++ fetchmail-6.3.26/socket.c 2017-11-13 18:16:35.450860469 +0100
-@@ -914,7 +914,8 @@ int SSLOpen(int sock, char *mycert, char
+Description:
Finally, you can use SSL for complete +-end-to-end encryption if you have an SSL-enabled mailserver.
++Finally, you can use SSL or TLS for complete ++end-to-end encryption if you have a TLS-enabled mailserver.
+ +You'll need to have the OpenSSL libraries installed, and they +-should at least be version 0.9.7. ++should at least be version 0.9.8, with 1.0.1 preferred. + Configure with --with-ssl. If you have the OpenSSL libraries + installed in commonly-used default locations, this will + suffice. If you have them installed in a non-default location, +@@ -2130,7 +2130,7 @@ to --with-ssl after an equal sign.
+Fetchmail binaries built this way support ssl
,
+ sslkey
, and sslcert
options that control
+ SSL encryption, and will automatically use tls
if the
+-server offers it. You will need to have an SSL-enabled mailserver to
++server offers it. You will need to have an SSL/TLS-enabled mailserver to
+ use these options. See the manual page for details and some words
+ of care on the limited security provided.
You should note that SSL is only secure against a "man-in-the-middle" +-attack if the client is able to verify that the peer's public key is the +-correct one, and has not been substituted by an attacker. fetchmail can do +-this in one of two ways: by verifying the SSL certificate, or by checking +-the fingerprint of the peer's public key.
++You should note that SSL or TLS are only secure against a ++"man-in-the-middle" attack if the client is able to verify that the ++peer's public key is the correct one, and has not been substituted by an ++attacker. fetchmail can do this in one of two ways: by verifying the SSL ++certificate, or by checking the fingerprint of the peer's public ++key.
+ +-There are three parts to SSL certificate verification: checking that the ++
There are three parts to TLS certificate verification: checking that the + domain name in the certificate matches the hostname you asked to connect to; + checking that the certificate expiry date has not passed; and checking that + the certificate has been signed by a known Certificate Authority (CA). This +@@ -2227,8 +2228,12 @@ will automatically attempt TLS negotiati + time. This can however cause problems if the upstream didn't configure + his certificates properly.
+ +-In order to prevent fetchmail from trying TLS (STLS, STARTTLS) +-negotiation, add this option:
++In order to prevent fetchmail 6.4.0 and newer versions from trying ++STLS or STARTTLS negotiation, add this option:
++sslproto ''++ ++
In order to prevent older fetchmail versions from trying TLS (STLS, STARTTLS) ++negotiation where the above does not work, try this option:
+ +sslproto ssl23+ +@@ -2876,15 +2881,22 @@ need to say something like '
envelo
+
+
+ Received: from send103.yahoomail.com (send103.yahoomail.com [205.180.60.92])
+- by iserv.ttns.net (8.8.5/8.8.5) with SMTP id RAA10088
+- for <ksturgeon@fbceg.org>; Wed, 9 Sep 1998 17:01:59 -0700
++ by iserv.example.net (8.8.5/8.8.5) with SMTP id RAA10088
++ for <ksturgeon@fbceg.example.org>; Wed, 9 Sep 1998 17:01:59 -0700
+
+
+-it checks to see if 'iserv.ttns.net' is a DNS alias of your
+-mailserver before accepting 'ksturgeon@fbceg.org' as an envelope
++
it checks to see if 'iserv.example.net' is a DNS alias of your
++mailserver before accepting 'ksturgeon@fbceg.example.org' as an envelope
+ address. This check might fail if your DNS were misconfigured, or
+-if you were using 'no dns' and had failed to declare iserv.ttns.net
+-as an alias of your server.
++if you were using 'no dns' and had failed to declare iserv.example.net
++as an alias of your server. The typical hint is logging similar to:
++line rejected, iserv.example.net is not an alias of the mailserver
,
++if you use fetchmail in verbose mode.
++
++Workaround: You can specify the alias explicitly, with aka
++ iserv.example.net
statements in the rcfile. Replace
++iserv.example.net by the name you find in your
++'by' part of the 'Received:' line.
+
+ M8. Users are getting multiple copies of
+ messages.
+@@ -3237,6 +3249,8 @@ Hayes mode escape "+++".
+ X8. A spurious ) is being appended to my
+ messages.
+
++Fetchmail 6.3.5 and newer releases are supposed to fix this.
++
+ Due to the problem described in S2, the
+ IMAP support in fetchmail cannot follow the IMAP protocol 100 %.
+ Most of the time it doesn't matter, but if you combine it with an
+@@ -3279,8 +3293,6 @@ it at the end of the message it forwards
+ on, you'll get a message about actual != expected.
+
+
+-
There is no fix for this.
+-
+ X9. Missing "Content-Transfer-Encoding" header
+ with Domino IMAP
+
+--- fetchmail-6.3.26.orig/fetchmail.c
++++ fetchmail-6.3.26/fetchmail.c
+@@ -54,6 +54,10 @@
+ #define ENETUNREACH 128 /* Interactive doesn't know this */
+ #endif /* ENETUNREACH */
+
++#ifdef SSL_ENABLE
++#include /* for OPENSSL_NO_SSL2 and ..._SSL3 checks */
++#endif
++
+ /* prototypes for internal functions */
+ static int load_params(int, char **, int);
+ static void dump_params (struct runctl *runp, struct query *, flag implicit);
+@@ -138,7 +142,7 @@ static void printcopyright(FILE *fp) {
+ "Copyright (C) 2004 Matthias Andree, Eric S. Raymond,\n"
+ " Robert M. Funk, Graham Wilson\n"
+ "Copyright (C) 2005 - 2012 Sunil Shetye\n"
+- "Copyright (C) 2005 - 2013 Matthias Andree\n"
++ "Copyright (C) 2005 - 2015 Matthias Andree\n"
+ ));
+ fprintf(fp, GT_("Fetchmail comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"
+ "are welcome to redistribute it under certain conditions. For details,\n"
+@@ -262,6 +266,9 @@ int main(int argc, char **argv)
+ #endif /* ODMR_ENABLE */
+ #ifdef SSL_ENABLE
+ "+SSL"
++#if (HAVE_DECL_SSLV3_CLIENT_METHOD + 0 == 0) || defined(OPENSSL_NO_SSL3)
++ "-SSLv3"
++#endif
+ #endif
+ #ifdef OPIE_ENABLE
+ "+OPIE"
+--- fetchmail-6.3.26.orig/fetchmail.h
++++ fetchmail-6.3.26/fetchmail.h
+@@ -771,9 +771,9 @@ int servport(const char *service);
+ int fm_getaddrinfo(const char *node, const char *serv, const struct addrinfo *hints, struct addrinfo **res);
+ void fm_freeaddrinfo(struct addrinfo *ai);
+
+-/* prototypes from tls.c */
+-int maybe_tls(struct query *ctl);
+-int must_tls(struct query *ctl);
++/* prototypes from starttls.c */
++int maybe_starttls(struct query *ctl);
++int must_starttls(struct query *ctl);
+
+ /* prototype from rfc822valid.c */
+ int rfc822_valid_msgid(const unsigned char *);
+--- fetchmail-6.3.26.orig/fetchmail.man
++++ fetchmail-6.3.26/fetchmail.man
+@@ -412,23 +412,22 @@ from. The folder information is written
+ .B \-\-ssl
+ (Keyword: ssl)
+ .br
+-Causes the connection to the mail server to be encrypted
+-via SSL. Connect to the server using the specified base protocol over a
+-connection secured by SSL. This option defeats opportunistic starttls
+-negotiation. It is highly recommended to use \-\-sslproto 'SSL3'
+-\-\-sslcertck to validate the certificates presented by the server and
+-defeat the obsolete SSLv2 negotiation. More information is available in
+-the \fIREADME.SSL\fP file that ships with fetchmail.
+-.IP
+-Note that fetchmail may still try to negotiate SSL through starttls even
+-if this option is omitted. You can use the \-\-sslproto option to defeat
+-this behavior or tell fetchmail to negotiate a particular SSL protocol.
++Causes the connection to the mail server to be encrypted via SSL, by
++negotiating SSL directly after connecting (SSL-wrapped mode). It is
++highly recommended to use \-\-sslcertck to validate the certificates
++presented by the server. Please see the description of \-\-sslproto
++below! More information is available in the \fIREADME.SSL\fP file that
++ships with fetchmail.
++.IP
++Note that even if this option is omitted, fetchmail may still negotiate
++SSL in-band for POP3 or IMAP, through the STLS or STARTTLS feature. You
++can use the \-\-sslproto option to modify that behavior.
+ .IP
+ If no port is specified, the connection is attempted to the well known
+ port of the SSL version of the base protocol. This is generally a
+ different port than the port used by the base protocol. For IMAP, this
+ is port 143 for the clear protocol and port 993 for the SSL secured
+-protocol, for POP3, it is port 110 for the clear text and port 995 for
++protocol; for POP3, it is port 110 for the clear text and port 995 for
+ the encrypted variant.
+ .IP
+ If your system lacks the corresponding entries from /etc/services, see
+@@ -470,39 +469,73 @@ cause some complications in daemon mode.
+ .IP
+ Also see \-\-sslcert above.
+ .TP
+-.B \-\-sslproto
+-(Keyword: sslproto)
++.B \-\-sslproto
++(Keyword: sslproto, NOTE: semantic changes since v6.4.0)
+ .br
+-Forces an SSL/TLS protocol. Possible values are \fB''\fP,
+-\&'\fBSSL2\fP' (not supported on all systems),
+-\&'\fBSSL23\fP', (use of these two values is discouraged
+-and should only be used as a last resort) \&'\fBSSL3\fP', and
+-\&'\fBTLS1\fP'. The default behaviour if this option is unset is: for
+-connections without \-\-ssl, use \&'\fBTLS1\fP' so that fetchmail will
+-opportunistically try STARTTLS negotiation with TLS1. You can configure
+-this option explicitly if the default handshake (TLS1 if \-\-ssl is not
+-used) does not work for your server.
+-.IP
+-Use this option with '\fBTLS1\fP' value to enforce a STARTTLS
+-connection. In this mode, it is highly recommended to also use
+-\-\-sslcertck (see below). Note that this will then cause fetchmail
+-v6.3.19 to force STARTTLS negotiation even if it is not advertised by
+-the server.
+-.IP
+-To defeat opportunistic TLSv1 negotiation when the server advertises
+-STARTTLS or STLS, and use a cleartext connection use \fB''\fP. This
+-option, even if the argument is the empty string, will also suppress the
+-diagnostic 'SERVER: opportunistic upgrade to TLS.' message in verbose
+-mode. The default is to try appropriate protocols depending on context.
++This option has a dual use, out of historic fetchmail behaviour. It
++controls both the SSL/TLS protocol version and, if \-\-ssl is not
++specified, the STARTTLS behaviour (upgrading the protocol to an SSL or
++TLS connection in-band). Some other options may however make TLS
++mandatory.
++.PP
++Only if this option and \-\-ssl are both missing for a poll, there will
++be opportunistic TLS for POP3 and IMAP, where fetchmail will attempt to
++upgrade to TLSv1 or newer.
++.PP
++Recognized values for \-\-sslproto are given below. You should normally
++chose one of the auto-negotiating options, i. e. '\fBauto\fP' or one of
++the options ending in a plus (\fB+\fP) character. Note that depending
++on OpenSSL library version and configuration, some options cause
++run-time errors because the requested SSL or TLS versions are not
++supported by the particular installed OpenSSL library.
++.RS
++.IP "\fB''\fP, the empty string"
++Disable STARTTLS. If \-\-ssl is given for the same server, log an error
++and pretend that '\fBauto\fP' had been used instead.
++.IP '\fBauto\fP'
++(default). Since v6.4.0. Require TLS. Auto-negotiate TLSv1 or newer, disable SSLv3 downgrade.
++(fetchmail 6.3.26 and older have auto-negotiated all protocols that
++their OpenSSL library supported, including the broken SSLv3).
++.IP "\&'\fBSSL23\fP'
++see '\fBauto\fP'.
++.IP \&'\fBSSL3\fP'
++Require SSLv3 exactly. SSLv3 is broken, not supported on all systems, avoid it
++if possible. This will make fetchmail negotiate SSLv3 only, and is the
++only way besides '\fBSSL3+\fP' to have fetchmail 6.4.0 or newer permit SSLv3.
++.IP \&'\fBSSL3+\fP'
++same as '\fBauto\fP', but permit SSLv3 as well. This is the only way
++besides '\fBSSL3\fP' to have fetchmail 6.4.0 or newer permit SSLv3.
++.IP \&'\fBTLS1\fP'
++Require TLSv1. This does not negotiate TLSv1.1 or newer, and is
++discouraged. Replace by TLS1+ unless the latter chokes your server.
++.IP \&'\fBTLS1+\fP'
++Since v6.4.0. See 'fBauto\fP'.
++.IP \&'\fBTLS1.1\fP'
++Since v6.4.0. Require TLS v1.1 exactly.
++.IP \&'\fBTLS1.1+\fP'
++Since v6.4.0. Require TLS. Auto-negotiate TLSv1.1 or newer.
++.IP \&'\fBTLS1.2\fP'
++Since v6.4.0. Require TLS v1.2 exactly.
++.IP '\fBTLS1.2+\fP'
++Since v6.4.0. Require TLS. Auto-negotiate TLSv1.2 or newer.
++.IP "Unrecognized parameters"
++are treated the same as '\fBauto\fP'.
++.RE
++.IP
++NOTE: you should hardly ever need to use anything other than '' (to
++force an unencrypted connection) or 'auto' (to enforce TLS).
+ .TP
+ .B \-\-sslcertck
+ (Keyword: sslcertck)
+ .br
+-Causes fetchmail to strictly check the server certificate against a set of
+-local trusted certificates (see the \fBsslcertfile\fP and \fBsslcertpath\fP
+-options). If the server certificate cannot be obtained or is not signed by one
+-of the trusted ones (directly or indirectly), the SSL connection will fail,
+-regardless of the \fBsslfingerprint\fP option.
++Causes fetchmail to require that SSL/TLS be used and disconnect if it
++can not successfully negotiate SSL or TLS, or if it cannot successfully
++verify and validate the certificate and follow it to a trust anchor (or
++trusted root certificate). The trust anchors are given as a set of local
++trusted certificates (see the \fBsslcertfile\fP and \fBsslcertpath\fP
++options). If the server certificate cannot be obtained or is not signed
++by one of the trusted ones (directly or indirectly), fetchmail will
++disconnect, regardless of the \fBsslfingerprint\fP option.
+ .IP
+ Note that CRL (certificate revocation lists) are only supported in
+ OpenSSL 0.9.7 and newer! Your system clock should also be reasonably
+@@ -1202,31 +1235,33 @@ capability response. Specify a user opti
+ username and the part to the right as the NTLM domain.
+
+ .SS Secure Socket Layers (SSL) and Transport Layer Security (TLS)
++.PP All retrieval protocols can use SSL or TLS wrapping for the
++transport. Additionally, POP3 and IMAP retrival can also negotiate
++SSL/TLS by means of STARTTLS (or STLS).
+ .PP
+ Note that fetchmail currently uses the OpenSSL library, which is
+ severely underdocumented, so failures may occur just because the
+ programmers are not aware of OpenSSL's requirement of the day.
+ For instance, since v6.3.16, fetchmail calls
+ OpenSSL_add_all_algorithms(), which is necessary to support certificates
+-using SHA256 on OpenSSL 0.9.8 -- this information is deeply hidden in the
+-documentation and not at all obvious. Please do not hesitate to report
+-subtle SSL failures.
+-.PP
+-You can access SSL encrypted services by specifying the \-\-ssl option.
+-You can also do this using the "ssl" user option in the .fetchmailrc
+-file. With SSL encryption enabled, queries are initiated over a
+-connection after negotiating an SSL session, and the connection fails if
+-SSL cannot be negotiated. Some services, such as POP3 and IMAP, have
++using SHA256 on OpenSSL 0.9.8 -- this information is deeply hidden in
++the documentation and not at all obvious. Please do not hesitate to
++report subtle SSL failures.
++.PP
++You can access SSL encrypted services by specifying the options starting
++with \-\-ssl, such as \-\-ssl, \-\-sslproto, \-\-sslcertck, and others.
++You can also do this using the corresponding user options in the .fetchmailrc
++file. Some services, such as POP3 and IMAP, have
+ different well known ports defined for the SSL encrypted services. The
+ encrypted ports will be selected automatically when SSL is enabled and
+-no explicit port is specified. The \-\-sslproto 'SSL3' option should be
+-used to select the SSLv3 protocol (default if unset: v2 or v3). Also,
+-the \-\-sslcertck command line or sslcertck run control file option
+-should be used to force strict certificate checking - see below.
++no explicit port is specified. Also, the \-\-sslcertck command line or
++sslcertck run control file option should be used to force strict
++certificate checking - see below.
+ .PP
+ If SSL is not configured, fetchmail will usually opportunistically try to use
+-STARTTLS. STARTTLS can be enforced by using \-\-sslproto "TLS1". TLS
+-connections use the same port as the unencrypted version of the
++STARTTLS. STARTTLS can be enforced by using \-\-sslproto\~auto and
++defeated by using \-\-sslproto\~''.
++TLS connections use the same port as the unencrypted version of the
+ protocol and negotiate TLS via special command. The \-\-sslcertck
+ command line or sslcertck run control file option should be used to
+ force strict certificate checking - see below.
+--- fetchmail-6.3.26.orig/imap.c
++++ fetchmail-6.3.26/imap.c
+@@ -405,6 +405,8 @@ static int imap_getauth(int sock, struct
+ /* apply for connection authorization */
+ {
+ int ok = 0;
++ char *commonname;
++
+ (void)greeting;
+
+ /*
+@@ -429,25 +431,21 @@ static int imap_getauth(int sock, struct
+ return(PS_SUCCESS);
+ }
+
+-#ifdef SSL_ENABLE
+- if (maybe_tls(ctl)) {
+- char *commonname;
+-
+- commonname = ctl->server.pollname;
+- if (ctl->server.via)
+- commonname = ctl->server.via;
+- if (ctl->sslcommonname)
+- commonname = ctl->sslcommonname;
++ commonname = ctl->server.pollname;
++ if (ctl->server.via)
++ commonname = ctl->server.via;
++ if (ctl->sslcommonname)
++ commonname = ctl->sslcommonname;
+
+- if (strstr(capabilities, "STARTTLS")
+- || must_tls(ctl)) /* if TLS is mandatory, ignore capabilities */
++#ifdef SSL_ENABLE
++ if (maybe_starttls(ctl)) {
++ if ((strstr(capabilities, "STARTTLS") && maybe_starttls(ctl))
++ || must_starttls(ctl)) /* if TLS is mandatory, ignore capabilities */
+ {
+- /* Use "tls1" rather than ctl->sslproto because tls1 is the only
+- * protocol that will work with STARTTLS. Don't need to worry
+- * whether TLS is mandatory or opportunistic unless SSLOpen() fails
+- * (see below). */
++ /* Don't need to worry whether TLS is mandatory or
++ * opportunistic unless SSLOpen() fails (see below). */
+ if (gen_transact(sock, "STARTTLS") == PS_SUCCESS
+- && (set_timeout(mytimeout), SSLOpen(sock, ctl->sslcert, ctl->sslkey, "tls1", ctl->sslcertck,
++ && (set_timeout(mytimeout), SSLOpen(sock, ctl->sslcert, ctl->sslkey, ctl->sslproto, ctl->sslcertck,
+ ctl->sslcertfile, ctl->sslcertpath, ctl->sslfingerprint, commonname,
+ ctl->server.pollname, &ctl->remotename)) != -1)
+ {
+@@ -470,7 +468,7 @@ static int imap_getauth(int sock, struct
+ {
+ report(stdout, GT_("%s: upgrade to TLS succeeded.\n"), commonname);
+ }
+- } else if (must_tls(ctl)) {
++ } else if (must_starttls(ctl)) {
+ /* Config required TLS but we couldn't guarantee it, so we must
+ * stop. */
+ set_timeout(0);
+@@ -492,6 +490,10 @@ static int imap_getauth(int sock, struct
+ /* Usable. Proceed with authenticating insecurely. */
+ }
+ }
++ } else {
++ if (strstr(capabilities, "STARTTLS") && outlevel >= O_VERBOSE) {
++ report(stdout, GT_("%s: WARNING: server offered STARTTLS but sslproto '' given.\n"), commonname);
++ }
+ }
+ #endif /* SSL_ENABLE */
+
+--- fetchmail-6.3.26.orig/po/Makevars
++++ fetchmail-6.3.26/po/Makevars
+@@ -46,3 +46,15 @@ MSGID_BUGS_ADDRESS = fetchmail-devel@lis
+ # This is the list of locale categories, beyond LC_MESSAGES, for which the
+ # message catalogs shall be used. It is usually empty.
+ EXTRA_LOCALE_CATEGORIES =
++
++# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
++# context. Possible values are "yes" and "no". Set this to yes if the
++# package uses functions taking also a message context, like pgettext(), or
++# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
++USE_MSGCTXT = no
++
++# These options get passed to msgmerge.
++# Useful options are in particular:
++# --previous to keep previous msgids of translated messages,
++# --quiet to reduce the verbosity.
++MSGMERGE_OPTIONS =
+--- fetchmail-6.3.26.orig/pop3.c
++++ fetchmail-6.3.26/pop3.c
+@@ -281,6 +281,7 @@ static int pop3_getauth(int sock, struct
+ #endif /* OPIE_ENABLE */
+ #ifdef SSL_ENABLE
+ flag connection_may_have_tls_errors = FALSE;
++ char *commonname;
+ #endif /* SSL_ENABLE */
+
+ done_capa = FALSE;
+@@ -393,7 +394,7 @@ static int pop3_getauth(int sock, struct
+ (ctl->server.authenticate == A_KERBEROS_V5) ||
+ (ctl->server.authenticate == A_OTP) ||
+ (ctl->server.authenticate == A_CRAM_MD5) ||
+- maybe_tls(ctl))
++ maybe_starttls(ctl))
+ {
+ if ((ok = capa_probe(sock)) != PS_SUCCESS)
+ /* we are in STAGE_GETAUTH => failure is PS_AUTHFAIL! */
+@@ -406,12 +407,12 @@ static int pop3_getauth(int sock, struct
+ (ok == PS_SOCKET && !ctl->wehaveauthed))
+ {
+ #ifdef SSL_ENABLE
+- if (must_tls(ctl)) {
++ if (must_starttls(ctl)) {
+ /* fail with mandatory STLS without repoll */
+ report(stderr, GT_("TLS is mandatory for this session, but server refused CAPA command.\n"));
+ report(stderr, GT_("The CAPA command is however necessary for TLS.\n"));
+ return ok;
+- } else if (maybe_tls(ctl)) {
++ } else if (maybe_starttls(ctl)) {
+ /* defeat opportunistic STLS */
+ xfree(ctl->sslproto);
+ ctl->sslproto = xstrdup("");
+@@ -431,24 +432,19 @@ static int pop3_getauth(int sock, struct
+ }
+
+ #ifdef SSL_ENABLE
+- if (maybe_tls(ctl)) {
+- char *commonname;
++ commonname = ctl->server.pollname;
++ if (ctl->server.via)
++ commonname = ctl->server.via;
++ if (ctl->sslcommonname)
++ commonname = ctl->sslcommonname;
+
+- commonname = ctl->server.pollname;
+- if (ctl->server.via)
+- commonname = ctl->server.via;
+- if (ctl->sslcommonname)
+- commonname = ctl->sslcommonname;
+-
+- if (has_stls
+- || must_tls(ctl)) /* if TLS is mandatory, ignore capabilities */
++ if (maybe_starttls(ctl)) {
++ if (has_stls || must_starttls(ctl)) /* if TLS is mandatory, ignore capabilities */
+ {
+- /* Use "tls1" rather than ctl->sslproto because tls1 is the only
+- * protocol that will work with STARTTLS. Don't need to worry
+- * whether TLS is mandatory or opportunistic unless SSLOpen() fails
+- * (see below). */
++ /* Don't need to worry whether TLS is mandatory or
++ * opportunistic unless SSLOpen() fails (see below). */
+ if (gen_transact(sock, "STLS") == PS_SUCCESS
+- && (set_timeout(mytimeout), SSLOpen(sock, ctl->sslcert, ctl->sslkey, "tls1", ctl->sslcertck,
++ && (set_timeout(mytimeout), SSLOpen(sock, ctl->sslcert, ctl->sslkey, ctl->sslproto, ctl->sslcertck,
+ ctl->sslcertfile, ctl->sslcertpath, ctl->sslfingerprint, commonname,
+ ctl->server.pollname, &ctl->remotename)) != -1)
+ {
+@@ -475,7 +471,7 @@ static int pop3_getauth(int sock, struct
+ {
+ report(stdout, GT_("%s: upgrade to TLS succeeded.\n"), commonname);
+ }
+- } else if (must_tls(ctl)) {
++ } else if (must_starttls(ctl)) {
+ /* Config required TLS but we couldn't guarantee it, so we must
+ * stop. */
+ set_timeout(0);
+@@ -495,7 +491,11 @@ static int pop3_getauth(int sock, struct
+ }
+ }
+ }
+- } /* maybe_tls() */
++ } else { /* maybe_starttls() */
++ if (has_stls && outlevel >= O_VERBOSE) {
++ report(stdout, GT_("%s: WARNING: server offered STLS, but sslproto '' given.\n"), commonname);
++ }
++ } /* maybe_starttls() */
+ #endif /* SSL_ENABLE */
+
+ /*
+--- fetchmail-6.3.26.orig/socket.c
++++ fetchmail-6.3.26/socket.c
+@@ -876,7 +876,9 @@ int SSLOpen(int sock, char *mycert, char
+ {
+ struct stat randstat;
+ int i;
++ int avoid_ssl_versions = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3;
+ long sslopts = SSL_OP_ALL;
++ int ssle_connect = 0;
+
+ SSL_load_error_strings();
+ SSL_library_init();
+@@ -906,25 +908,57 @@ int SSLOpen(int sock, char *mycert, char
+ /* Make sure a connection referring to an older context is not left */
+ _ssl_context[sock] = NULL;
+ if(myproto) {
+- if(!strcasecmp("ssl2",myproto)) {
+-#if HAVE_DECL_SSLV2_CLIENT_METHOD + 0 > 0
+- _ctx[sock] = SSL_CTX_new(SSLv2_client_method());
++ if(!strcasecmp("ssl3",myproto)) {
++#if (HAVE_DECL_SSLV3_CLIENT_METHOD > 0) && (0 == OPENSSL_NO_SSL3 + 0)
++ _ctx[sock] = SSL_CTX_new(SSLv3_client_method());
++ avoid_ssl_versions &= ~SSL_OP_NO_SSLv3;
+ #else
+- report(stderr, GT_("Your operating system does not support SSLv2.\n"));
++ report(stderr, GT_("Your OpenSSL version does not support SSLv3.\n"));
return -1;
#endif
- } else if(!strcasecmp("ssl3",myproto)) {
+- } else if(!strcasecmp("ssl3",myproto)) {
- _ctx[sock] = SSL_CTX_new(SSLv3_client_method());
-+ report(stderr, GT_("Your operating system does not support SSLv3.\n"));
-+ return -1;
++ } else if(!strcasecmp("ssl3+",myproto)) {
++ avoid_ssl_versions &= ~SSL_OP_NO_SSLv3;
++ myproto = NULL;
} else if(!strcasecmp("tls1",myproto)) {
_ctx[sock] = SSL_CTX_new(TLSv1_client_method());
- } else if (!strcasecmp("ssl23",myproto)) {
+- } else if (!strcasecmp("ssl23",myproto)) {
++ } else if(!strcasecmp("tls1+",myproto)) {
++ myproto = NULL;
++#if defined(TLS1_1_VERSION) && TLS_MAX_VERSION >= TLS1_1_VERSION
++ } else if(!strcasecmp("tls1.1",myproto)) {
++ _ctx[sock] = SSL_CTX_new(TLSv1_1_client_method());
++ } else if(!strcasecmp("tls1.1+",myproto)) {
++ myproto = NULL;
++ avoid_ssl_versions |= SSL_OP_NO_TLSv1;
++#else
++ } else if(!strcasecmp("tls1.1",myproto) || !strcasecmp("tls1.1+", myproto)) {
++ report(stderr, GT_("Your OpenSSL version does not support TLS v1.1.\n"));
++ return -1;
++#endif
++#if defined(TLS1_2_VERSION) && TLS_MAX_VERSION >= TLS1_2_VERSION
++ } else if(!strcasecmp("tls1.2",myproto)) {
++ _ctx[sock] = SSL_CTX_new(TLSv1_2_client_method());
++ } else if(!strcasecmp("tls1.2+",myproto)) {
++ myproto = NULL;
++ avoid_ssl_versions |= SSL_OP_NO_TLSv1;
++ avoid_ssl_versions |= SSL_OP_NO_TLSv1_1;
++#else
++ } else if(!strcasecmp("tls1.2",myproto) || !strcasecmp("tls1.2+", myproto)) {
++ report(stderr, GT_("Your OpenSSL version does not support TLS v1.2.\n"));
++ return -1;
++#endif
++ } else if (!strcasecmp("ssl23",myproto) || 0 == strcasecmp("auto",myproto)) {
+ myproto = NULL;
+ } else {
+- report(stderr,GT_("Invalid SSL protocol '%s' specified, using default (SSLv23).\n"), myproto);
++ report(stderr,GT_("Invalid SSL protocol '%s' specified, using default autoselect (SSL23).\n"), myproto);
+ myproto = NULL;
+ }
+ }
+- if(!myproto) {
++ // do not combine into an else { } as myproto may be nulled
++ // above!
++ if (!myproto) {
++ // SSLv23 is a misnomer and will in fact use the best
++ // available protocol, subject to SSL_OP_NO*
++ // constraints.
+ _ctx[sock] = SSL_CTX_new(SSLv23_client_method());
+ }
+ if(_ctx[sock] == NULL) {
+@@ -938,7 +972,7 @@ int SSLOpen(int sock, char *mycert, char
+ sslopts &= ~ SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
+ }
+
+- SSL_CTX_set_options(_ctx[sock], sslopts);
++ SSL_CTX_set_options(_ctx[sock], sslopts | avoid_ssl_versions);
+
+ if (certck) {
+ SSL_CTX_set_verify(_ctx[sock], SSL_VERIFY_PEER, SSL_ck_verify_callback);
+@@ -1008,8 +1042,18 @@ int SSLOpen(int sock, char *mycert, char
+ }
+
+ if (SSL_set_fd(_ssl_context[sock], sock) == 0
+- || SSL_connect(_ssl_context[sock]) < 1) {
++ || (ssle_connect = SSL_connect(_ssl_context[sock])) < 1) {
++ int e = errno;
++ unsigned long ssle_err_from_queue = ERR_peek_error();
++ unsigned long ssle_err_from_get_error = SSL_get_error(_ssl_context[sock], ssle_connect);
+ ERR_print_errors_fp(stderr);
++ if (SSL_ERROR_SYSCALL == ssle_err_from_get_error && 0 == ssle_err_from_queue) {
++ if (0 == ssle_connect) {
++ report(stderr, GT_("Server shut down connection prematurely during SSL_connect().\n"));
++ } else if (ssle_connect < 0) {
++ report(stderr, GT_("System error during SSL_connect(): %s\n"), strerror(e));
++ }
++ }
+ SSL_free( _ssl_context[sock] );
+ _ssl_context[sock] = NULL;
+ SSL_CTX_free(_ctx[sock]);
+@@ -1017,6 +1061,24 @@ int SSLOpen(int sock, char *mycert, char
+ return(-1);
+ }
+
++ if (outlevel >= O_VERBOSE) {
++ SSL_CIPHER const *sc;
++ int bitsmax, bitsused;
++
++ const char *ver;
++
++ ver = SSL_get_version(_ssl_context[sock]);
++
++ sc = SSL_get_current_cipher(_ssl_context[sock]);
++ if (!sc) {
++ report (stderr, GT_("Cannot obtain current SSL/TLS cipher - no session established?\n"));
++ } else {
++ bitsused = SSL_CIPHER_get_bits(sc, &bitsmax);
++ report(stdout, GT_("SSL/TLS: using protocol %s, cipher %s, %d/%d secret/processed bits\n"),
++ ver, SSL_CIPHER_get_name(sc), bitsused, bitsmax);
++ }
++ }
++
+ /* Paranoia: was the callback not called as we expected? */
+ if (!_depth0ck) {
+ report(stderr, GT_("Certificate/fingerprint verification was somehow skipped!\n"));
+--- /dev/null
++++ fetchmail-6.3.26/starttls.c
+@@ -0,0 +1,37 @@
++/** \file tls.c - collect common TLS functionality
++ * \author Matthias Andree
++ * \date 2006
++ */
++
++#include "fetchmail.h"
++
++#include
++
++#ifdef HAVE_STRINGS_H
++#include
++#endif
++
++/** return true if user allowed opportunistic STARTTLS/STLS */
++int maybe_starttls(struct query *ctl) {
++#ifdef SSL_ENABLE
++ /* opportunistic or forced TLS */
++ return (!ctl->sslproto || strlen(ctl->sslproto))
++ && !ctl->use_ssl;
++#else
++ (void)ctl;
++ return 0;
++#endif
++}
++
++/** return true if user requires STARTTLS/STLS, note though that this
++ * code must always use a logical AND with maybe_tls(). */
++int must_starttls(struct query *ctl) {
++#ifdef SSL_ENABLE
++ return maybe_starttls(ctl)
++ && (ctl->sslfingerprint || ctl->sslcertck
++ || (ctl->sslproto && !strcasecmp(ctl->sslproto, "tls1")));
++#else
++ (void)ctl;
++ return 0;
++#endif
++}
diff --git a/fetchmail.changes b/fetchmail.changes
index 680ed5a..8e70278 100644
--- a/fetchmail.changes
+++ b/fetchmail.changes
@@ -1,3 +1,10 @@
+-------------------------------------------------------------------
+Wed May 29 11:58:18 UTC 2019 - Dr. Werner Fink
+
+- Use Debian 02_remove_SSLv3 change set based on beta 6.4.0 to
+ modernize the patch fetchmail-openssl11.patch for modern TLS
+ (auto) support
+
-------------------------------------------------------------------
Thu Mar 15 17:12:10 UTC 2018 - pmonrealgonzalez@suse.com
diff --git a/fetchmail.spec b/fetchmail.spec
index 5184306..bc758aa 100644
--- a/fetchmail.spec
+++ b/fetchmail.spec
@@ -1,7 +1,7 @@
#
# spec file for package fetchmail
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#