Session.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // Session.h
  3. //
  4. // Library: NetSSL_OpenSSL
  5. // Package: SSLCore
  6. // Module: Session
  7. //
  8. // Definition of the Session class.
  9. //
  10. // Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef NetSSL_Session_INCLUDED
  16. #define NetSSL_Session_INCLUDED
  17. #include "Poco/Net/NetSSL.h"
  18. #include "Poco/RefCountedObject.h"
  19. #include "Poco/AutoPtr.h"
  20. #include <openssl/ssl.h>
  21. namespace Poco {
  22. namespace Net {
  23. class NetSSL_API Session: public Poco::RefCountedObject
  24. /// This class encapsulates a SSL session object
  25. /// used with session caching on the client side.
  26. ///
  27. /// For session caching to work, a client must
  28. /// save the session object from an existing connection,
  29. /// if it wants to reuse it with a future connection.
  30. {
  31. public:
  32. typedef Poco::AutoPtr<Session> Ptr;
  33. SSL_SESSION* sslSession() const;
  34. /// Returns the stored OpenSSL SSL_SESSION object.
  35. protected:
  36. Session(SSL_SESSION* pSession);
  37. /// Creates a new Session object, using the given
  38. /// SSL_SESSION object.
  39. ///
  40. /// The SSL_SESSION's reference count is not changed.
  41. ~Session();
  42. /// Destroys the Session.
  43. ///
  44. /// Calls SSL_SESSION_free() on the stored
  45. /// SSL_SESSION object.
  46. private:
  47. Session();
  48. SSL_SESSION* _pSession;
  49. friend class SecureSocketImpl;
  50. };
  51. //
  52. // inlines
  53. //
  54. inline SSL_SESSION* Session::sslSession() const
  55. {
  56. return _pSession;
  57. }
  58. } } // namespace Poco::Net
  59. #endif // NetSSL_Session_INCLUDED