gnutls-3.4.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 2a5868411c57e25802d2f16fd6b77601f10d0b72 Mon Sep 17 00:00:00 2001
  2. From: Nikos Mavrogiannopoulos <nmav@redhat.com>
  3. Date: Fri, 29 Apr 2016 22:58:34 +0200
  4. Subject: [PATCH] Updated gnutls certificate callback to new API (backwards
  5. compatible)
  6. ---
  7. src/idevice.c | 13 +++++++++++++
  8. 1 file changed, 13 insertions(+)
  9. diff --git a/src/idevice.c b/src/idevice.c
  10. index 5912aeb..f2de6a3 100644
  11. --- a/src/idevice.c
  12. +++ b/src/idevice.c
  13. @@ -642,7 +642,11 @@ static const char *ssl_error_to_string(int e)
  14. /**
  15. * Internally used gnutls callback function that gets called during handshake.
  16. */
  17. +#if GNUTLS_VERSION_NUMBER >= 0x020b07
  18. +static int internal_cert_callback(gnutls_session_t session, const gnutls_datum_t * req_ca_rdn, int nreqs, const gnutls_pk_algorithm_t * sign_algos, int sign_algos_length, gnutls_retr2_st * st)
  19. +#else
  20. static int internal_cert_callback(gnutls_session_t session, const gnutls_datum_t * req_ca_rdn, int nreqs, const gnutls_pk_algorithm_t * sign_algos, int sign_algos_length, gnutls_retr_st * st)
  21. +#endif
  22. {
  23. int res = -1;
  24. gnutls_certificate_type_t type = gnutls_certificate_type_get(session);
  25. @@ -650,7 +654,12 @@ static int internal_cert_callback(gnutls_session_t session, const gnutls_datum_t
  26. ssl_data_t ssl_data = (ssl_data_t)gnutls_session_get_ptr(session);
  27. if (ssl_data && ssl_data->host_privkey && ssl_data->host_cert) {
  28. debug_info("Passing certificate");
  29. +#if GNUTLS_VERSION_NUMBER >= 0x020b07
  30. + st->cert_type = type;
  31. + st->key_type = GNUTLS_PRIVKEY_X509;
  32. +#else
  33. st->type = type;
  34. +#endif
  35. st->ncerts = 1;
  36. st->cert.x509 = &ssl_data->host_cert;
  37. st->key.x509 = ssl_data->host_privkey;
  38. @@ -759,7 +768,11 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_conne
  39. debug_info("enabling SSL mode");
  40. errno = 0;
  41. gnutls_certificate_allocate_credentials(&ssl_data_loc->certificate);
  42. +#if GNUTLS_VERSION_NUMBER >= 0x020b07
  43. + gnutls_certificate_set_retrieve_function(ssl_data_loc->certificate, internal_cert_callback);
  44. +#else
  45. gnutls_certificate_client_set_retrieve_function(ssl_data_loc->certificate, internal_cert_callback);
  46. +#endif
  47. gnutls_init(&ssl_data_loc->session, GNUTLS_CLIENT);
  48. gnutls_priority_set_direct(ssl_data_loc->session, "NONE:+VERS-SSL3.0:+ANON-DH:+RSA:+AES-128-CBC:+AES-256-CBC:+SHA1:+MD5:+COMP-NULL", NULL);
  49. gnutls_credentials_set(ssl_data_loc->session, GNUTLS_CRD_CERTIFICATE, ssl_data_loc->certificate);