Adam Tkac | b10489b | 2010-04-23 14:16:04 +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 |
|
Adam Tkac | 3c5be39 | 2010-07-21 09:27:34 +0000 | [diff] [blame] | 22 | #ifndef __C_SECURITY_TLS_H__
|
| 23 | #define __C_SECURITY_TLS_H__
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 24 |
|
| 25 | #ifdef HAVE_CONFIG_H
|
| 26 | #include <config.h>
|
| 27 | #endif
|
| 28 |
|
Adam Tkac | 4395823 | 2010-07-21 09:06:59 +0000 | [diff] [blame] | 29 | #ifndef HAVE_GNUTLS
|
| 30 | #error "This header should not be compiled without HAVE_GNUTLS defined"
|
| 31 | #endif
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 32 |
|
| 33 | #include <rfb/CSecurity.h>
|
Adam Tkac | 0e61c34 | 2010-07-21 09:23:25 +0000 | [diff] [blame] | 34 | #include <rfb/SSecurityVeNCrypt.h>
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 35 | #include <rfb/Security.h>
|
| 36 | #include <rdr/InStream.h>
|
| 37 | #include <rdr/OutStream.h>
|
| 38 | #include <gnutls/gnutls.h>
|
| 39 |
|
| 40 | namespace rfb {
|
Adam Tkac | 3c5be39 | 2010-07-21 09:27:34 +0000 | [diff] [blame] | 41 | class CSecurityTLS : public CSecurity {
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 42 | public:
|
Adam Tkac | 3c5be39 | 2010-07-21 09:27:34 +0000 | [diff] [blame] | 43 | CSecurityTLS(bool _anon);
|
| 44 | virtual ~CSecurityTLS();
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 45 | virtual bool processMsg(CConnection* cc);
|
Adam Tkac | 0e61c34 | 2010-07-21 09:23:25 +0000 | [diff] [blame] | 46 | virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None; }
|
| 47 | virtual const char* description() const
|
| 48 | { return anon ? "TLS Encryption without VncAuth" : "X509 Encryption without VncAuth"; }
|
| 49 |
|
| 50 | static StringParameter x509ca;
|
| 51 | static StringParameter x509crl;
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 52 |
|
| 53 | protected:
|
| 54 | void shutdown();
|
Adam Tkac | 0e61c34 | 2010-07-21 09:23:25 +0000 | [diff] [blame] | 55 | void freeResources();
|
| 56 | void setParam();
|
| 57 | void checkSession();
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 58 | CConnection *client;
|
| 59 |
|
| 60 | private:
|
| 61 | static void initGlobal();
|
| 62 |
|
| 63 | gnutls_session session;
|
Adam Tkac | 0e61c34 | 2010-07-21 09:23:25 +0000 | [diff] [blame] | 64 | gnutls_anon_client_credentials anon_cred;
|
| 65 | gnutls_certificate_credentials cert_cred;
|
| 66 | bool anon;
|
| 67 |
|
| 68 | char *cafile, *crlfile;
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 69 | rdr::InStream* fis;
|
| 70 | rdr::OutStream* fos;
|
| 71 | };
|
| 72 | }
|
| 73 |
|
Adam Tkac | b10489b | 2010-04-23 14:16:04 +0000 | [diff] [blame] | 74 | #endif
|