You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CSecurityTLS.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #ifndef __C_SECURITY_TLS_H__
  22. #define __C_SECURITY_TLS_H__
  23. #ifdef HAVE_CONFIG_H
  24. #include <config.h>
  25. #endif
  26. #ifndef HAVE_GNUTLS
  27. #error "This header should not be compiled without HAVE_GNUTLS defined"
  28. #endif
  29. #include <rfb/CSecurity.h>
  30. #include <rfb/Security.h>
  31. #include <rfb/UserMsgBox.h>
  32. #include <rdr/InStream.h>
  33. #include <rdr/OutStream.h>
  34. #include <gnutls/gnutls.h>
  35. namespace rfb {
  36. class UserMsgBox;
  37. class CSecurityTLS : public CSecurity {
  38. public:
  39. CSecurityTLS(CConnection* cc, bool _anon);
  40. virtual ~CSecurityTLS();
  41. virtual bool processMsg();
  42. virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None; }
  43. virtual const char* description() const
  44. { return anon ? "TLS Encryption without VncAuth" : "X509 Encryption without VncAuth"; }
  45. virtual bool isSecure() const { return !anon; }
  46. static void setDefaults();
  47. static StringParameter X509CA;
  48. static StringParameter X509CRL;
  49. static UserMsgBox *msg;
  50. protected:
  51. void shutdown(bool needbye);
  52. void freeResources();
  53. void setParam();
  54. void checkSession();
  55. CConnection *client;
  56. private:
  57. gnutls_session_t session;
  58. gnutls_anon_client_credentials_t anon_cred;
  59. gnutls_certificate_credentials_t cert_cred;
  60. bool anon;
  61. char *cafile, *crlfile;
  62. rdr::InStream* tlsis;
  63. rdr::OutStream* tlsos;
  64. rdr::InStream* rawis;
  65. rdr::OutStream* rawos;
  66. };
  67. }
  68. #endif