blob: 6f711824b3d379276dfe9078d9a1199072205bf4 [file] [log] [blame]
Adam Tkacdfe19cf2010-04-23 14:14:11 +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
Adam Tkac21b61a52010-07-21 09:19:00 +000022#ifndef __S_SECURITY_TLS_H__
23#define __S_SECURITY_TLS_H__
Adam Tkacdfe19cf2010-04-23 14:14:11 +000024
25#ifdef HAVE_CONFIG_H
26#include <config.h>
27#endif
28
Adam Tkacdf799702010-04-28 15:45:53 +000029#ifndef HAVE_GNUTLS
30#error "This header should not be included without HAVE_GNUTLS defined"
31#endif
Adam Tkacdfe19cf2010-04-23 14:14:11 +000032
33#include <rfb/SSecurity.h>
Adam Tkacf39671d2010-07-21 09:10:54 +000034#include <rfb/SSecurityVeNCrypt.h>
Adam Tkacdfe19cf2010-04-23 14:14:11 +000035#include <rdr/InStream.h>
36#include <rdr/OutStream.h>
37#include <gnutls/gnutls.h>
38
39namespace rfb {
40
Adam Tkac21b61a52010-07-21 09:19:00 +000041 class SSecurityTLS : public SSecurity {
Adam Tkacdfe19cf2010-04-23 14:14:11 +000042 public:
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020043 SSecurityTLS(SConnection* sc, bool _anon);
Adam Tkac21b61a52010-07-21 09:19:00 +000044 virtual ~SSecurityTLS();
Pierre Ossmanad2b3c42018-09-21 15:31:11 +020045 virtual bool processMsg();
Adam Tkacdfe19cf2010-04-23 14:14:11 +000046 virtual const char* getUserName() const {return 0;}
Adam Tkacf39671d2010-07-21 09:10:54 +000047 virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None;}
48
49 static StringParameter X509_CertFile;
50 static StringParameter X509_KeyFile;
Adam Tkacdfe19cf2010-04-23 14:14:11 +000051
52 protected:
53 void shutdown();
Pierre Ossman88c24ed2015-01-29 13:12:22 +010054 void setParams(gnutls_session_t session);
Adam Tkacdfe19cf2010-04-23 14:14:11 +000055
56 private:
Pierre Ossman88c24ed2015-01-29 13:12:22 +010057 gnutls_session_t session;
58 gnutls_dh_params_t dh_params;
59 gnutls_anon_server_credentials_t anon_cred;
60 gnutls_certificate_credentials_t cert_cred;
Adam Tkacf39671d2010-07-21 09:10:54 +000061 char *keyfile, *certfile;
62
63 int type;
64 bool anon;
65
Pierre Ossman1b746342018-09-21 15:33:30 +020066 rdr::InStream* tlsis;
67 rdr::OutStream* tlsos;
Pierre Ossman06c11992018-09-21 15:34:47 +020068
69 rdr::InStream* rawis;
70 rdr::OutStream* rawos;
Adam Tkacdfe19cf2010-04-23 14:14:11 +000071 };
72
73}
74
Adam Tkacdfe19cf2010-04-23 14:14:11 +000075#endif