blob: 476d0ef87b7c0c396a66b450f29a52e90bb2784d [file] [log] [blame]
Adam Tkac5522d612010-08-11 15:28:01 +00001/*
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>
Adam Tkac5522d612010-08-11 15:28:01 +000034#include <rfb/Security.h>
Adam Tkac27b2f772010-11-18 13:33:57 +000035#include <rfb/UserMsgBox.h>
Adam Tkac5522d612010-08-11 15:28:01 +000036#include <rdr/InStream.h>
37#include <rdr/OutStream.h>
38#include <gnutls/gnutls.h>
39
40namespace rfb {
Adam Tkac27b2f772010-11-18 13:33:57 +000041 class UserMsgBox;
Adam Tkac5522d612010-08-11 15:28:01 +000042 class CSecurityTLS : public CSecurity {
43 public:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020044 CSecurityTLS(CConnection* cc, bool _anon);
Adam Tkac5522d612010-08-11 15:28:01 +000045 virtual ~CSecurityTLS();
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020046 virtual bool processMsg();
Adam Tkac5522d612010-08-11 15:28:01 +000047 virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None; }
48 virtual const char* description() const
49 { return anon ? "TLS Encryption without VncAuth" : "X509 Encryption without VncAuth"; }
Pierre Ossmandaf3d882017-09-01 11:14:35 +020050 virtual bool isSecure() const { return !anon; }
Adam Tkac27b2f772010-11-18 13:33:57 +000051 static void setDefaults();
Adam Tkac5522d612010-08-11 15:28:01 +000052
Pierre Ossman3d2a84b2014-09-17 16:45:35 +020053 static StringParameter X509CA;
54 static StringParameter X509CRL;
Adam Tkac27b2f772010-11-18 13:33:57 +000055 static UserMsgBox *msg;
Adam Tkac5522d612010-08-11 15:28:01 +000056
57 protected:
Adam Tkac44cdb132011-02-09 14:09:10 +000058 void shutdown(bool needbye);
Adam Tkac5522d612010-08-11 15:28:01 +000059 void freeResources();
60 void setParam();
61 void checkSession();
62 CConnection *client;
63
64 private:
Pierre Ossman88c24ed2015-01-29 13:12:22 +010065 gnutls_session_t session;
66 gnutls_anon_client_credentials_t anon_cred;
67 gnutls_certificate_credentials_t cert_cred;
Adam Tkac5522d612010-08-11 15:28:01 +000068 bool anon;
69
70 char *cafile, *crlfile;
Pierre Ossman1b746342018-09-21 15:33:30 +020071
72 rdr::InStream* tlsis;
73 rdr::OutStream* tlsos;
Pierre Ossman06c11992018-09-21 15:34:47 +020074
75 rdr::InStream* rawis;
76 rdr::OutStream* rawos;
Adam Tkac5522d612010-08-11 15:28:01 +000077 };
78}
79
80#endif