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
16
17#ifndef NetSSL_Session_INCLUDED
18#define NetSSL_Session_INCLUDED
19
20
21#include "Poco/Net/NetSSL.h"
22#include "Poco/RefCountedObject.h"
23#include "Poco/AutoPtr.h"
24#include <openssl/ssl.h>
25
26
27namespace Poco {
28namespace Net {
29
30
31class NetSSL_API Session: public Poco::RefCountedObject
32 /// This class encapsulates a SSL session object
33 /// used with session caching on the client side.
34 ///
35 /// For session caching to work, a client must
36 /// save the session object from an existing connection,
37 /// if it wants to reuse it with a future connection.
38{
39public:
40 typedef Poco::AutoPtr<Session> Ptr;
41
42 SSL_SESSION* sslSession() const;
43 /// Returns the stored OpenSSL SSL_SESSION object.
44
45protected:
46 Session(SSL_SESSION* pSession);
47 /// Creates a new Session object, using the given
48 /// SSL_SESSION object.
49 ///
50 /// The SSL_SESSION's reference count is not changed.
51
52 ~Session();
53 /// Destroys the Session.
54 ///
55 /// Calls SSL_SESSION_free() on the stored
56 /// SSL_SESSION object.
57
58private:
59 Session();
60
61 SSL_SESSION* _pSession;
62
63 friend class SecureSocketImpl;
64};
65
66
67//
68// inlines
69//
70inline SSL_SESSION* Session::sslSession() const
71{
72 return _pSession;
73}
74
75
76} } // namespace Poco::Net
77
78
79#endif // NetSSL_Session_INCLUDED
80