diff options
author | Pierre Ossman <ossman@cendio.se> | 2012-07-03 14:43:38 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2012-07-03 14:43:38 +0000 |
commit | fe48cd4d2427c0262cd58b30c74331a9fce756c7 (patch) | |
tree | 453992f3361da2899981bbfe360f3cbfa0a56e5e /common/rfb/SSecurityTLS.cxx | |
parent | ae60016b2aa97b7cf78dcb52a4ef8aa4ebb45a39 (diff) | |
download | tigervnc-fe48cd4d2427c0262cd58b30c74331a9fce756c7.tar.gz tigervnc-fe48cd4d2427c0262cd58b30c74331a9fce756c7.zip |
Refactor the TLS code so that the push/pull functions are aware of their
containing stream object. This is in preparation for supporting GnuTLS 3.x.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4921 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/SSecurityTLS.cxx')
-rw-r--r-- | common/rfb/SSecurityTLS.cxx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/common/rfb/SSecurityTLS.cxx b/common/rfb/SSecurityTLS.cxx index 9a34f3a7..7a1a41ef 100644 --- a/common/rfb/SSecurityTLS.cxx +++ b/common/rfb/SSecurityTLS.cxx @@ -148,17 +148,19 @@ bool SSecurityTLS::processMsg(SConnection *sc) throw; } - gnutls_transport_set_pull_function(session,rdr::gnutls_InStream_pull); - gnutls_transport_set_push_function(session,rdr::gnutls_OutStream_push); - gnutls_transport_set_ptr2(session, - (gnutls_transport_ptr)is, - (gnutls_transport_ptr)os); os->writeU8(1); os->flush(); } + rdr::TLSInStream *tlsis = new rdr::TLSInStream(is, session); + rdr::TLSOutStream *tlsos = new rdr::TLSOutStream(os, session); + int err; - if ((err = gnutls_handshake(session)) != GNUTLS_E_SUCCESS) { + err = gnutls_handshake(session); + if (err != GNUTLS_E_SUCCESS) { + delete tlsis; + delete tlsos; + if (!gnutls_error_is_fatal(err)) { vlog.debug("Deferring completion of TLS handshake: %s", gnutls_strerror(err)); return false; @@ -170,8 +172,7 @@ bool SSecurityTLS::processMsg(SConnection *sc) vlog.debug("Handshake completed"); - sc->setStreams(fis=new rdr::TLSInStream(is,session), - fos=new rdr::TLSOutStream(os,session)); + sc->setStreams(fis = tlsis, fos = tlsos); return true; } |