Botan: Botan::TLS_Client Class Reference

Botan 1.10.17

Public Member Functions | List of all members
Botan::TLS_Client Class Reference

`#include <tls_client.h>`

Inheritance diagram for Botan::TLS_Client:

## Public Member Functions
void | add_client_cert (const X509_Certificate &cert, Private_Key *cert_key)
void | close ()
bool | is_closed () const
std::vector< X509_Certificate > | peer_cert_chain () const
size_t | read (byte &in)
size_t | read (byte buf[], size_t buf_len)
| 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 (byte out)
void | write (const byte buf[], size_t buf_len)
| ~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.

References close().

106 {
107 close();
108 for(size_t i = 0; i != certs.size(); i++)
109 delete certs[i].second;
110 delete state;
111 }
Botan::TLS_Client::close
void close()
Definition: tls_client.cpp:204

## 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.

References Botan::CLOSE_NOTIFY, and Botan::WARNING.

Referenced by ~TLS_Client().

205 {
206 close(WARNING, CLOSE_NOTIFY);
207 }
Botan::WARNING
Definition: tls_magic.h:58
Botan::CLOSE_NOTIFY
Definition: tls_magic.h:63
Botan::TLS_Client::close
void close()
Definition: tls_client.cpp:204

## ◆ 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_Connection::read | ( | byte & | in | ) |
| inlineinherited

Definition at line 24 of file tls_connection.h.

References Botan::TLS_Connection::read().

Referenced by Botan::TLS_Connection::read().

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

## ◆ read() [2/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.

References Botan::Record_Writer::flush(), Botan::SecureQueue::read(), and Botan::SecureQueue::size().

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 }
Botan::SecureQueue::size
size_t size() const
Definition: secqueue.cpp:190
Botan::SecureQueue::read
size_t read(byte[], size_t)
Definition: secqueue.cpp:137
Botan::Record_Writer::flush
void flush()
Definition: rec_wri.cpp:162

## ◆ write() [1/2]

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

Definition at line 25 of file tls_connection.h.

References Botan::TLS_Connection::write().

Referenced by Botan::TLS_Connection::write().

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

## ◆ write() [2/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.

References Botan::APPLICATION_DATA, Botan::INTERNAL_ERROR, and Botan::Record_Writer::send().

171 {
172 if(!active)
173 throw TLS_Exception(INTERNAL_ERROR,
174 "TLS_Client::write called while closed");
175
176 writer.send(APPLICATION_DATA, buf, length);
177 }
Botan::APPLICATION_DATA
Definition: tls_magic.h:37
Botan::INTERNAL_ERROR
Definition: tls_magic.h:83
Botan::Record_Writer::send
void send(byte type, const byte input[], size_t length)
Definition: rec_wri.cpp:131

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

- src/ssl/tls_client.h
- src/ssl/tls_client.cpp