2023-02-08 11:04:11 +00:00
|
|
|
//
|
|
|
|
// Session.h
|
|
|
|
//
|
|
|
|
// Library: NetSSL_OpenSSL
|
|
|
|
// Package: SSLCore
|
|
|
|
// Module: Session
|
|
|
|
//
|
|
|
|
// Definition of the Session class.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef NetSSL_Session_INCLUDED
|
|
|
|
#define NetSSL_Session_INCLUDED
|
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
#include <openssl/ssl.h>
|
|
|
|
#include "Poco/AutoPtr.h"
|
2023-02-08 11:04:11 +00:00
|
|
|
#include "Poco/Net/NetSSL.h"
|
|
|
|
#include "Poco/RefCountedObject.h"
|
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
namespace Net
|
|
|
|
{
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
class NetSSL_API Session : public Poco::RefCountedObject
|
|
|
|
/// This class encapsulates a SSL session object
|
|
|
|
/// used with session caching on the client side.
|
|
|
|
///
|
|
|
|
/// For session caching to work, a client must
|
|
|
|
/// save the session object from an existing connection,
|
|
|
|
/// if it wants to reuse it with a future connection.
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Poco::AutoPtr<Session> Ptr;
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
SSL_SESSION * sslSession() const;
|
|
|
|
/// Returns the stored OpenSSL SSL_SESSION object.
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
protected:
|
|
|
|
Session(SSL_SESSION * pSession);
|
|
|
|
/// Creates a new Session object, using the given
|
|
|
|
/// SSL_SESSION object.
|
|
|
|
///
|
|
|
|
/// The SSL_SESSION's reference count is not changed.
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
~Session();
|
|
|
|
/// Destroys the Session.
|
|
|
|
///
|
|
|
|
/// Calls SSL_SESSION_free() on the stored
|
|
|
|
/// SSL_SESSION object.
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
private:
|
|
|
|
Session();
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
SSL_SESSION * _pSession;
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
friend class SecureSocketImpl;
|
|
|
|
};
|
2023-02-08 11:04:11 +00:00
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// inlines
|
|
|
|
//
|
|
|
|
inline SSL_SESSION * Session::sslSession() const
|
|
|
|
{
|
|
|
|
return _pSession;
|
|
|
|
}
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
|
2023-02-13 09:22:33 +00:00
|
|
|
}
|
|
|
|
} // namespace Poco::Net
|
2023-02-08 11:04:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif // NetSSL_Session_INCLUDED
|