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.

SSecurityTLS.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 __S_SECURITY_TLS_H__
  22. #define __S_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 included without HAVE_GNUTLS defined"
  28. #endif
  29. #include <rfb/SSecurity.h>
  30. #include <rfb/SSecurityVeNCrypt.h>
  31. #include <rdr/InStream.h>
  32. #include <rdr/OutStream.h>
  33. #include <gnutls/gnutls.h>
  34. namespace rfb {
  35. class SSecurityTLS : public SSecurity {
  36. public:
  37. SSecurityTLS(SConnection* sc, bool _anon);
  38. virtual ~SSecurityTLS();
  39. virtual bool processMsg();
  40. virtual const char* getUserName() const {return 0;}
  41. virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None;}
  42. static StringParameter X509_CertFile;
  43. static StringParameter X509_KeyFile;
  44. protected:
  45. void shutdown();
  46. void setParams(gnutls_session_t session);
  47. private:
  48. gnutls_session_t session;
  49. gnutls_dh_params_t dh_params;
  50. gnutls_anon_server_credentials_t anon_cred;
  51. gnutls_certificate_credentials_t cert_cred;
  52. char *keyfile, *certfile;
  53. bool anon;
  54. rdr::InStream* tlsis;
  55. rdr::OutStream* tlsos;
  56. rdr::InStream* rawis;
  57. rdr::OutStream* rawos;
  58. };
  59. }
  60. #endif