]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/lib/openssl.c
authorAlain Spineux <alain@baculasystems.com>
Thu, 23 Apr 2020 13:58:53 +0000 (15:58 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:16 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Thu Mar 19 18:09:32 2020 +0100

    more work on QT5 for windows

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Wed Jan 8 14:40:42 2020 +0100

    Fix #5829 about OpenBSD compilation issue with TLS 1.3 code

    The SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY seems to not be defined
    on OpenBSD. Probably a compatibility issue.

    Compiling openssl.c
    openssl.c: In function 'void openssl_post_errors(JCR*, int, const char*)':
    openssl.c:67: error: 'SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY' was not declared in this scope

Author: Alain Spineux <alain@baculasystems.com>
Date:   Fri Jul 19 16:13:26 2019 +0200

    Fix OpenSSL TLS 1.3 message with ssl3_read_bytes:application data after close notify

      Ignore this error that is SSL_shutdown() specific and is new to TLS 1.3
      ERR=error:14094123:SSL routines:ssl3_read_bytes:application data after close notify
      we are doing the TLS shutdown.
      This can happens at multiple place but the message appears only on
      the DIR because at that time the connection with the DIR is often "terminated"

bacula/src/lib/openssl.c

index 1c8581b5ce7e8ce2efe8dd4d7c971addcdf948a4..ef9a0627e44619785a2532c7f1074f6991054a81 100644 (file)
@@ -65,6 +65,19 @@ void openssl_post_errors(JCR *jcr, int code, const char *errstring)
       /* Acquire the human readable string */
       ERR_error_string_n(sslerr, buf, sizeof(buf));
       Dmsg3(50, "jcr=%p %s: ERR=%s\n", jcr, errstring, buf);
+#if (OPENSSL_VERSION_NUMBER > 0x10101000L) && defined(SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY)
+      if (ERR_GET_REASON(sslerr) == SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY) {
+       /* Ignore this error that is SSL_shutdown() specific and is new to TLS 1.3
+        * error:14094123:SSL routines:ssl3_read_bytes:application data after close notify
+        *
+        * This happens when there is still something to read in the socket
+        * while we are doing the TLS shutdown.  This can happens at multiple
+        * place but the message appears only on the DIR because at that time
+        * the connection with the DIR is often "terminated"
+        */
+         continue;
+      }
+#endif
       Qmsg2(jcr, M_ERROR, 0, "%s: ERR=%s\n", errstring, buf);
    }
 }
@@ -234,13 +247,16 @@ static int openssl_seed_prng (void)
    // Win32 Support
    // Read saved entropy?
 
+#ifdef HAVE_WIN32
+   return 1;
+#endif
+
    for (i = 0; names[i]; i++) {
       if (RAND_load_file(names[i], 1024) != -1) {
          /* Success */
          return 1;
       }
    }
-
    /* Fail */
    return 0;
 }
@@ -332,10 +348,29 @@ int cleanup_crypto (void)
    return 0;
 }
 
+const char *crypto_get_version()
+{
+#ifdef HAVE_OPENSSL_VERSION_TEXT
+   return OPENSSL_VERSION_TEXT;
+#else
+   return "OpenSSL";
+#endif
+}
+
 #else
 
 /* Dummy routines */
-int init_crypto (void) { return 0; }
-int cleanup_crypto (void) { return 0; }
+int init_crypto (void) {
+   return 0;
+}
+
+int cleanup_crypto (void) {
+   return 0;
+}
+
+const char *crypto_get_version()
+{
+   return "*None*";
+}
 
 #endif /* HAVE_OPENSSL */