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 1.9KB

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