Adam Tkac | 5522d61 | 2010-08-11 15:28:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004 Red Hat Inc. |
| 3 | * Copyright (C) 2005 Martin Koegler |
| 4 | * Copyright (C) 2010 TigerVNC Team |
| 5 | * |
| 6 | * This is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This software is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this software; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 19 | * USA. |
| 20 | */ |
| 21 | |
| 22 | #ifndef __C_SECURITY_TLS_H__ |
| 23 | #define __C_SECURITY_TLS_H__ |
| 24 | |
| 25 | #ifdef HAVE_CONFIG_H |
| 26 | #include <config.h> |
| 27 | #endif |
| 28 | |
| 29 | #ifndef HAVE_GNUTLS |
| 30 | #error "This header should not be compiled without HAVE_GNUTLS defined" |
| 31 | #endif |
| 32 | |
| 33 | #include <rfb/CSecurity.h> |
| 34 | #include <rfb/SSecurityVeNCrypt.h> |
| 35 | #include <rfb/Security.h> |
Adam Tkac | 27b2f77 | 2010-11-18 13:33:57 +0000 | [diff] [blame] | 36 | #include <rfb/UserMsgBox.h> |
Adam Tkac | 5522d61 | 2010-08-11 15:28:01 +0000 | [diff] [blame] | 37 | #include <rdr/InStream.h> |
| 38 | #include <rdr/OutStream.h> |
| 39 | #include <gnutls/gnutls.h> |
| 40 | |
| 41 | namespace rfb { |
Adam Tkac | 27b2f77 | 2010-11-18 13:33:57 +0000 | [diff] [blame] | 42 | class UserMsgBox; |
Adam Tkac | 5522d61 | 2010-08-11 15:28:01 +0000 | [diff] [blame] | 43 | class CSecurityTLS : public CSecurity { |
| 44 | public: |
| 45 | CSecurityTLS(bool _anon); |
| 46 | virtual ~CSecurityTLS(); |
| 47 | virtual bool processMsg(CConnection* cc); |
| 48 | virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None; } |
| 49 | virtual const char* description() const |
| 50 | { return anon ? "TLS Encryption without VncAuth" : "X509 Encryption without VncAuth"; } |
Pierre Ossman | daf3d88 | 2017-09-01 11:14:35 +0200 | [diff] [blame^] | 51 | virtual bool isSecure() const { return !anon; } |
Adam Tkac | 27b2f77 | 2010-11-18 13:33:57 +0000 | [diff] [blame] | 52 | static void setDefaults(); |
Adam Tkac | 5522d61 | 2010-08-11 15:28:01 +0000 | [diff] [blame] | 53 | |
Pierre Ossman | 3d2a84b | 2014-09-17 16:45:35 +0200 | [diff] [blame] | 54 | static StringParameter X509CA; |
| 55 | static StringParameter X509CRL; |
Adam Tkac | 27b2f77 | 2010-11-18 13:33:57 +0000 | [diff] [blame] | 56 | static UserMsgBox *msg; |
Adam Tkac | 5522d61 | 2010-08-11 15:28:01 +0000 | [diff] [blame] | 57 | |
| 58 | protected: |
Adam Tkac | 44cdb13 | 2011-02-09 14:09:10 +0000 | [diff] [blame] | 59 | void shutdown(bool needbye); |
Adam Tkac | 5522d61 | 2010-08-11 15:28:01 +0000 | [diff] [blame] | 60 | void freeResources(); |
| 61 | void setParam(); |
| 62 | void checkSession(); |
| 63 | CConnection *client; |
| 64 | |
| 65 | private: |
Pierre Ossman | 88c24ed | 2015-01-29 13:12:22 +0100 | [diff] [blame] | 66 | gnutls_session_t session; |
| 67 | gnutls_anon_client_credentials_t anon_cred; |
| 68 | gnutls_certificate_credentials_t cert_cred; |
Adam Tkac | 5522d61 | 2010-08-11 15:28:01 +0000 | [diff] [blame] | 69 | bool anon; |
| 70 | |
| 71 | char *cafile, *crlfile; |
| 72 | rdr::InStream* fis; |
| 73 | rdr::OutStream* fos; |
| 74 | }; |
| 75 | } |
| 76 | |
| 77 | #endif |