Botan 1.10.17
Botan::TLS_Client Class Reference

#include <tls_client.h>

Inheritance diagram for Botan::TLS_Client:
Botan::TLS_Connection

Public Member Functions

void add_client_cert (const X509_Certificate &cert, Private_Key *cert_key)
void close ()
bool is_closed () const
std::vector< X509_Certificatepeer_cert_chain () const
size_t read (byte buf[], size_t buf_len)
size_t read (byte &in)
 TLS_Client (std::tr1::function< size_t(byte[], size_t)> input_fn, std::tr1::function< void(const byte[], size_t)> output_fn, const TLS_Policy &policy, RandomNumberGenerator &rng)
void write (const byte buf[], size_t buf_len)
void write (byte out)
 ~TLS_Client ()

Detailed Description

SSL/TLS Client

Definition at line 22 of file tls_client.h.

Constructor & Destructor Documentation

◆ TLS_Client()

Botan::TLS_Client::TLS_Client ( std::tr1::function< size_t(byte[], size_t)> input_fn,
std::tr1::function< void(const byte[], size_t)> output_fn,
const TLS_Policy & policy,
RandomNumberGenerator & rng )

TLS Client Constructor

Definition at line 84 of file tls_client.cpp.

87 :
88 input_fn(input_fn),
89 policy(policy),
90 rng(rng),
91 writer(output_fn)
92 {
93 initialize();
94 }

◆ ~TLS_Client()

Botan::TLS_Client::~TLS_Client ( )

TLS Client Destructor

Definition at line 105 of file tls_client.cpp.

106 {
107 close();
108 for(size_t i = 0; i != certs.size(); i++)
109 delete certs[i].second;
110 delete state;
111 }

References close().

Member Function Documentation

◆ add_client_cert()

void Botan::TLS_Client::add_client_cert ( const X509_Certificate & cert,
Private_Key * cert_key )

Definition at line 96 of file tls_client.cpp.

98 {
99 certs.push_back(std::make_pair(cert, cert_key));
100 }

◆ close()

void Botan::TLS_Client::close ( )
virtual

Close a TLS connection

Implements Botan::TLS_Connection.

Definition at line 204 of file tls_client.cpp.

205 {
207 }
@ CLOSE_NOTIFY
Definition tls_magic.h:63
@ WARNING
Definition tls_magic.h:58

References close(), Botan::CLOSE_NOTIFY, and Botan::WARNING.

Referenced by close(), and ~TLS_Client().

◆ is_closed()

bool Botan::TLS_Client::is_closed ( ) const

Check connection status

Definition at line 212 of file tls_client.cpp.

213 {
214 if(!active)
215 return true;
216 return false;
217 }

◆ peer_cert_chain()

std::vector< X509_Certificate > Botan::TLS_Client::peer_cert_chain ( ) const
virtual

Return the peer's certificate chain

Implements Botan::TLS_Connection.

Definition at line 162 of file tls_client.cpp.

163 {
164 return peer_certs;
165 }

◆ read() [1/2]

size_t Botan::TLS_Client::read ( byte out[],
size_t length )
virtual

Read from a TLS connection

Implements Botan::TLS_Connection.

Definition at line 182 of file tls_client.cpp.

183 {
184 if(!active)
185 return 0;
186
187 writer.flush();
188
189 while(read_buf.size() == 0)
190 {
191 state_machine();
192 if(active == false)
193 break;
194 }
195
196 size_t got = std::min<size_t>(read_buf.size(), length);
197 read_buf.read(out, got);
198 return got;
199 }

◆ read() [2/2]

size_t Botan::TLS_Connection::read ( byte & in)
inlineinherited

Definition at line 24 of file tls_connection.h.

24{ return read(&in, 1); }
virtual size_t read(byte[], size_t)=0

References read().

Referenced by read().

◆ write() [1/2]

void Botan::TLS_Client::write ( const byte buf[],
size_t length )
virtual

Write to a TLS connection

Implements Botan::TLS_Connection.

Definition at line 170 of file tls_client.cpp.

171 {
172 if(!active)
174 "TLS_Client::write called while closed");
175
176 writer.send(APPLICATION_DATA, buf, length);
177 }
TLS_Exception(Alert_Type type, const std::string &err_msg="Unknown error")
Definition tls_exceptn.h:24
@ INTERNAL_ERROR
Definition tls_magic.h:83
@ APPLICATION_DATA
Definition tls_magic.h:37

References Botan::APPLICATION_DATA, Botan::INTERNAL_ERROR, and Botan::TLS_Exception::TLS_Exception().

◆ write() [2/2]

void Botan::TLS_Connection::write ( byte out)
inlineinherited

Definition at line 25 of file tls_connection.h.

25{ write(&out, 1); }
virtual void write(const byte[], size_t)=0

References write().

Referenced by write().


The documentation for this class was generated from the following files: