From d228c9e24e78047afdd04fcc9e335551fea87251 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date: Sat, 11 Nov 2017 11:11:55 +0000
Subject: [PATCH 2/2] ftp-ssl: use get+set session instead of copy id

This does mostly the same thing but may be more obvious, maybe not.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
---
 ftp/ftp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/ftp/ftp.c
+++ b/ftp/ftp.c
@@ -94,6 +94,7 @@
 static int ptflag = 0;
 static int ptabflg = 0;
 #ifdef USE_SSL
+static SSL_SESSION *ssl_data_session;
 int             ssl_available=1;
 static int	pdata = -1;
 static int
@@ -1677,7 +1678,8 @@
 	     * this quick assuming Eric has this going
 	     * okay! ;-)
 	     */
-	    SSL_copy_session_id(ssl_data_con,ssl_con);
+	    if (ssl_data_session)
+		    SSL_set_session(ssl_data_con, ssl_data_session);
 
 	    /* we are doing I/O and not using select so 
 	     * it is "safe" to read ahead
@@ -2279,6 +2281,11 @@
 		    fprintf(stderr, "Data connection security level refused.\n");
 		    return ERROR;
 		}
+		if (ssl_encrypt_data) {
+			SSL_SESSION_free(ssl_data_session);
+			ssl_data_session = SSL_get1_session(ssl_con);
+		}
+
 		if (verbose && use_tls && ssl_encrypt_data)
 		    fprintf(stderr, "[Encrypted data transfer.]\n");
 	    }
