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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/SSecurityVeNCrypt.h>
  31. #include <rfb/Security.h>
  32. #include <rfb/UserMsgBox.h>
  33. #include <rdr/InStream.h>
  34. #include <rdr/OutStream.h>
  35. #include <gnutls/gnutls.h>
  36. namespace rfb {
  37. class UserMsgBox;
  38. class CSecurityTLS : public CSecurity {
  39. public:
  40. CSecurityTLS(bool _anon);
  41. virtual ~CSecurityTLS();
  42. virtual bool processMsg(CConnection* cc);
  43. virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None; }
  44. virtual const char* description() const
  45. { return anon ? "TLS Encryption without VncAuth" : "X509 Encryption without VncAuth"; }
  46. virtual bool isSecure() const { return !anon; }
  47. static void setDefaults();
  48. static StringParameter X509CA;
  49. static StringParameter X509CRL;
  50. static UserMsgBox *msg;
  51. protected:
  52. void shutdown(bool needbye);
  53. void freeResources();
  54. void setParam();
  55. void checkSession();
  56. CConnection *client;
  57. private:
  58. gnutls_session_t session;
  59. gnutls_anon_client_credentials_t anon_cred;
  60. gnutls_certificate_credentials_t cert_cred;
  61. bool anon;
  62. char *cafile, *crlfile;
  63. rdr::InStream* fis;
  64. rdr::OutStream* fos;
  65. };
  66. }
  67. #endif