SSLSession.h
Go to the documentation of this file.
/* Copyright 2019 OSU OPEnS Lab
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify,
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "bearssl.h"
#include "Arduino.h"
#include "IPAddress.h"
#ifndef SSLSession_H_
#define SSLSession_H_
class SSLSession : public br_ssl_session_parameters {
public:
SSLSession()
: m_valid_session(false)
, m_hostname()
, m_ip(INADDR_NONE) {}
SSLSession& operator=(const SSLSession&) = delete;
const String& get_hostname() const { return m_hostname; }
const IPAddress& get_ip() const { return m_ip; }
bool is_valid_session() const { return m_valid_session; }
void set_parameters(const IPAddress& ip, const char* hostname = NULL);
void clear_parameters();
br_ssl_session_parameters* to_br_session() { return (br_ssl_session_parameters *)this; }
private:
bool m_valid_session;
// aparently a hostname has a max length of 256 chars. Go figure.
String m_hostname;
// store the IP Address we connected to
IPAddress m_ip;
};
#endif /* SSLSession_H_ */
SSLSession
This class stores values which allow SSLClient to save and resume SSL sessions.
Definition: SSLSession.h:52
SSLSession::to_br_session
br_ssl_session_parameters * to_br_session()
Returns a pointer to the ::br_ssl_session_parameters component of this class.
Definition: SSLSession.h:121
SSLSession::set_parameters
void set_parameters(const IPAddress &ip, const char *hostname=NULL)
Set the ip address and hostname of the session.
Definition: SSLSession.cpp:4
SSLSession::clear_parameters
void clear_parameters()
Delete the parameters and invalidate the session.
Definition: SSLSession.cpp:19
SSLSession::is_valid_session
bool is_valid_session() const
Definition: SSLSession.h:88
SSLSession::operator=
SSLSession & operator=(const SSLSession &)=delete
use clear_parameters or set_parameters instead
SSLSession::get_ip
const IPAddress & get_ip() const
Get ::IPAddress associated with this session.
Definition: SSLSession.h:86
SSLSession::SSLSession
SSLSession()
SSLSession constructor.
Definition: SSLSession.h:60
SSLSession::get_hostname
const String & get_hostname() const
Get the hostname string associated with this session.
Definition: SSLSession.h:76