[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH stable-0.15 17/36] vns/tls: don't use depricated gn
From: |
Andreas Färber |
Subject: |
[Qemu-stable] [PATCH stable-0.15 17/36] vns/tls: don't use depricated gnutls functions |
Date: |
Wed, 28 Mar 2012 14:52:20 +0200 |
From: Gerd Hoffmann <address@hidden>
Avoid using deprecated gnutls functions with recent gnutls versions.
Fixes build failure on Fedora 16. Keep the old way for compatibility
with old installations such as RHEL-5 (gnutls 1.4.x).
Based on a patch from Raghavendra D Prabhu <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>
(cherry picked from commit f40d55081667a716312b9a8b6e13835c4074f56b)
Signed-off-by: Bruce Rogers <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
ui/vnc-tls.c | 68 +++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c
index 31f1467..f5ed306 100644
--- a/ui/vnc-tls.c
+++ b/ui/vnc-tls.c
@@ -283,13 +283,57 @@ int vnc_tls_validate_certificate(struct VncState *vs)
return 0;
}
+#if defined(GNUTLS_VERSION_NUMBER) && \
+ GNUTLS_VERSION_NUMBER >= 0x020200 /* 2.2.0 */
+
+static int vnc_set_gnutls_priority(gnutls_session_t s, int x509)
+{
+ const char *priority = x509 ? "NORMAL" : "NORMAL:+ANON-DH";
+ int rc;
+
+ rc = gnutls_priority_set_direct(s, priority, NULL);
+ if (rc != GNUTLS_E_SUCCESS) {
+ return -1;
+ }
+ return 0;
+}
+
+#else
+
+static int vnc_set_gnutls_priority(gnutls_session_t s, int x509)
+{
+ static const int cert_types[] = { GNUTLS_CRT_X509, 0 };
+ static const int protocols[] = {
+ GNUTLS_TLS1_1, GNUTLS_TLS1_0, GNUTLS_SSL3, 0
+ };
+ static const int kx_anon[] = { GNUTLS_KX_ANON_DH, 0 };
+ static const int kx_x509[] = {
+ GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA,
+ GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0
+ };
+ int rc;
+
+ rc = gnutls_kx_set_priority(s, x509 ? kx_x509 : kx_anon);
+ if (rc != GNUTLS_E_SUCCESS) {
+ return -1;
+ }
+
+ rc = gnutls_certificate_type_set_priority(s, cert_types);
+ if (rc != GNUTLS_E_SUCCESS) {
+ return -1;
+ }
+
+ rc = gnutls_protocol_set_priority(s, protocols);
+ if (rc != GNUTLS_E_SUCCESS) {
+ return -1;
+ }
+ return 0;
+}
+
+#endif
int vnc_tls_client_setup(struct VncState *vs,
int needX509Creds) {
- 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_anon[] = {GNUTLS_KX_ANON_DH, 0};
- static const int kx_x509[] = {GNUTLS_KX_DHE_DSS, GNUTLS_KX_RSA,
GNUTLS_KX_DHE_RSA, GNUTLS_KX_SRP, 0};
VNC_DEBUG("Do TLS setup\n");
if (vnc_tls_initialize() < 0) {
@@ -310,21 +354,7 @@ int vnc_tls_client_setup(struct VncState *vs,
return -1;
}
- if (gnutls_kx_set_priority(vs->tls.session, needX509Creds ? kx_x509 :
kx_anon) < 0) {
- gnutls_deinit(vs->tls.session);
- vs->tls.session = NULL;
- vnc_client_error(vs);
- return -1;
- }
-
- if (gnutls_certificate_type_set_priority(vs->tls.session,
cert_type_priority) < 0) {
- gnutls_deinit(vs->tls.session);
- vs->tls.session = NULL;
- vnc_client_error(vs);
- return -1;
- }
-
- if (gnutls_protocol_set_priority(vs->tls.session, protocol_priority) <
0) {
+ if (vnc_set_gnutls_priority(vs->tls.session, needX509Creds) < 0) {
gnutls_deinit(vs->tls.session);
vs->tls.session = NULL;
vnc_client_error(vs);
--
1.7.7
- [Qemu-stable] [PATCH stable-0.15 01/36] ccid: Fix buffer overrun in handling of VSC_ATR message, (continued)
- [Qemu-stable] [PATCH stable-0.15 01/36] ccid: Fix buffer overrun in handling of VSC_ATR message, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 11/36] acl: Fix use after free in qemu_acl_reset(), Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 25/36] block: Fix vpc initialization of the Dynamic Disk Header, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 13/36] Fix X86 CPU topology in KVM mode, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 07/36] kvm: avoid reentring kvm_flush_coalesced_mmio_buffer(), Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 10/36] ide: Fix off-by-one error in array index check, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 27/36] block: reinitialize across bdrv_close()/bdrv_open(), Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 20/36] hda: do not mix output and input stream states, RHBZ #740493, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 09/36] block: Fix bdrv_open use after free, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 23/36] block: set bs->read_only before .bdrv_open(), Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 17/36] vns/tls: don't use depricated gnutls functions,
Andreas Färber <=
- [Qemu-stable] [PATCH stable-0.15 08/36] vmdk: vmdk_read_cid returns garbage if p_name is NULL, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 29/36] vmdk: Fix possible segfaults, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 34/36] pc: fix event_idx compatibility for virtio devices, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 04/36] e1000: Don't set the Capabilities List bit, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 35/36] Add missing trace call to oslib-posix.c:qemu_vmalloc(), Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 03/36] e1000: use MII status register for link up/down, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 14/36] hw/lan9118.c: Add missing 'break' to fix buffer overrun, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 15/36] ac97: don't override the pci subsystem id, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 06/36] compatfd.c: Don't pass NULL pointer to SYS_signalfd, Andreas Färber, 2012/03/28
- [Qemu-stable] [PATCH stable-0.15 05/36] e1000: bounds packet size against buffer size, Andreas Färber, 2012/03/28