[gtk-vnc] Adapt to avoid deprecated gnutls functions



commit 4ef44ef1046d7fa07a9f3d7adbb72144c71ebc97
Author: Daniel P. Berrange <berrange redhat com>
Date:   Thu Dec 8 21:47:43 2011 +0000

    Adapt to avoid deprecated gnutls functions
    
    Switch to using gnutls_priority_set_direct on newer GNUTLS

 src/vncconnection.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 0a947f0..2068c54 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -3689,10 +3689,15 @@ static gboolean vnc_connection_perform_auth_sasl(VncConnection *conn)
 static gboolean vnc_connection_start_tls(VncConnection *conn, int anonTLS)
 {
 	VncConnectionPrivate *priv = conn->priv;
+#if defined(GNUTLS_VERSION_NUMBER) && \
+    GNUTLS_VERSION_NUMBER >= 0x020200 /* 2.2.0 */
+	const char *priority = anonTLS ? "NORMAL:+ANON-DH" : "NORMAL";
+#else
 	static const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 };
 	static const int protocol_priority[]= { GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0 };
 	static const int kx_priority[] = {GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0};
 	static const int kx_anon[] = {GNUTLS_KX_ANON_DH, 0};
+#endif
 	int ret;
 
 	VNC_DEBUG("Do TLS handshake");
@@ -3707,6 +3712,14 @@ static gboolean vnc_connection_start_tls(VncConnection *conn, int anonTLS)
 			return FALSE;
 		}
 
+#if defined(GNUTLS_VERSION_NUMBER) && \
+	GNUTLS_VERSION_NUMBER >= 0x020200 /* 2.2.0 */
+		if (gnutls_priority_set_direct(priv->tls_session, priority, NULL) < 0) {
+			gnutls_deinit(priv->tls_session);
+			priv->has_error = TRUE;
+			return FALSE;
+		}
+#else
 		if (gnutls_set_default_priority(priv->tls_session) < 0) {
 			gnutls_deinit(priv->tls_session);
 			priv->has_error = TRUE;
@@ -3730,6 +3743,7 @@ static gboolean vnc_connection_start_tls(VncConnection *conn, int anonTLS)
 			priv->has_error = TRUE;
 			return FALSE;
 		}
+#endif
 
 		if (anonTLS) {
 			gnutls_anon_client_credentials anon_cred = vnc_connection_tls_initialize_anon_cred();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]