rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | From 090017efca9396a7cef0ccdc645a88c5457c63b8 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jackie Huang <jackie.huang@windriver.com> |
| 3 | Date: Wed, 29 Jun 2016 01:22:46 -0400 |
| 4 | Subject: [PATCH] Replace deprecated function gnutls_protocol_set_priority |
| 5 | |
| 6 | The function gnutls_protocol_set_priority is deprecated |
| 7 | since GnuTLS >= 2.12.0 and replaced by gnutls_priority_set_direct. |
| 8 | |
| 9 | Reference: |
| 10 | http://www.gnutls.org/manual/html_node/Upgrading-from-previous-versions.html#Upgrading-from-previous-versions |
| 11 | |
| 12 | Upstream-Status: Inappropriate [upstream rewrote with GPLv3] |
| 13 | |
| 14 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> |
| 15 | --- |
| 16 | src/tls.c | 20 +++++++++++++++++--- |
| 17 | 1 file changed, 17 insertions(+), 3 deletions(-) |
| 18 | |
| 19 | diff --git a/src/tls.c b/src/tls.c |
| 20 | index 10818fa..881e94b 100644 |
| 21 | --- a/src/tls.c |
| 22 | +++ b/src/tls.c |
| 23 | @@ -928,7 +928,15 @@ int tls_init(tls_t *tls, const char *key_file, const char *cert_file, |
| 24 | const char *trust_file, int force_sslv3, char **errstr) |
| 25 | { |
| 26 | #ifdef HAVE_LIBGNUTLS |
| 27 | +#if GNUTLS_VERSION_MAJOR >= 2 && GNUTLS_VERSION_MINOR >= 12 |
| 28 | + const char *force_sslv3_str = ":-VERS-TLS-ALL:+VERS-SSL3.0"; |
| 29 | +#else |
| 30 | + const char *force_sslv3_str = |
| 31 | + ":-VERS-TLS1.2:-VERS-TLS1.1:-VERS-TLS1.0:+VERS-SSL3.0"; |
| 32 | +#endif |
| 33 | int error_code; |
| 34 | + char *priorities; |
| 35 | + const char *error_pos; |
| 36 | |
| 37 | if ((error_code = gnutls_init(&tls->session, GNUTLS_CLIENT)) != 0) |
| 38 | { |
| 39 | @@ -945,9 +953,15 @@ int tls_init(tls_t *tls, const char *key_file, const char *cert_file, |
| 40 | } |
| 41 | if (force_sslv3) |
| 42 | { |
| 43 | - const int force_sslv3_proto_prio[2] = { GNUTLS_SSL3, 0 }; |
| 44 | - if ((error_code = gnutls_protocol_set_priority(tls->session, |
| 45 | - force_sslv3_proto_prio)) != 0) |
| 46 | + priorities = xstrdup("NORMAL"); |
| 47 | + error_pos = NULL; |
| 48 | + |
| 49 | + priorities = xrealloc(priorities, |
| 50 | + strlen(priorities) + strlen(force_sslv3_str) + 1); |
| 51 | + strcat(priorities, force_sslv3_str); |
| 52 | + |
| 53 | + if ((error_code = gnutls_priority_set_direct(tls->session, |
| 54 | + priorities, &error_pos)) != 0) |
| 55 | { |
| 56 | *errstr = xasprintf(_("cannot force SSLv3: %s"), |
| 57 | gnutls_strerror(error_code)); |
| 58 | -- |
| 59 | 2.8.1 |
| 60 | |