Botan: Botan::TLS_Server Class Reference

Botan 1.10.17

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

`#include <tls_server.h>`

Inheritance diagram for Botan::TLS_Server:

## Public Member Functions
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)
std::string | requested_hostname () const
| TLS_Server (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, const X509_Certificate &cert, const Private_Key &cert_key)
void | write (const byte buf[], size_t buf_len)
void | write (byte out)
| ~TLS_Server ()

## Detailed Description

TLS Server

Definition at line 21 of file tls_server.h.

## Constructor & Destructor Documentation

## ◆ TLS_Server()

Botan::TLS_Server::TLS_Server | ( | 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,
|  | const X509_Certificate & | cert,
|  | const Private_Key & | cert_key
| ) |  |

Definition at line 88 of file tls_server.cpp.

93 :
94 input_fn(input_fn),
95 policy(policy),
96 rng(rng),
97 writer(output_fn)
98 {
99 state = 0;
100
101 cert_chain.push_back(cert);
102 private_key = PKCS8::copy_key(cert_key, rng);
103
104 try {
105 active = false;
106 writer.set_version(TLS_V10);
107 do_handshake();
108 active = true;
109 }
110 catch(std::exception& e)
111 {
112 if(state)
113 {
114 delete state;
115 state = 0;
116 }
117
118 writer.alert(FATAL, HANDSHAKE_FAILURE);
119 throw Stream_IO_Error(std::string("TLS_Server: Handshake failed: ") +
120 e.what());
121 }
122 }
Botan::HANDSHAKE_FAILURE
Definition: tls_magic.h:69
Botan::Record_Writer::set_version
void set_version(Version_Code)
Definition: rec_wri.cpp:51
Botan::TLS_V10
Definition: tls_magic.h:25
Botan::PKCS8::copy_key
Private_Key * copy_key(const Private_Key &key, RandomNumberGenerator &rng)
Definition: pkcs8.cpp:250
Botan::Record_Writer::alert
void alert(Alert_Level, Alert_Type)
Definition: rec_wri.cpp:264
Botan::FATAL
Definition: tls_magic.h:59

## ◆ ~TLS_Server()

Botan::TLS_Server::~TLS_Server | ( |  | ) |

Definition at line 127 of file tls_server.cpp.

References close().

128 {
129 close();
130 delete private_key;
131 delete state;
132 }
Botan::TLS_Server::close
void close()
Definition: tls_server.cpp:188

## Member Function Documentation

## ◆ close()

void Botan::TLS_Server::close | ( |  | ) |
| virtual

Implements Botan::TLS_Connection.

Definition at line 188 of file tls_server.cpp.

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

Referenced by ~TLS_Server().

189 {
190 close(WARNING, CLOSE_NOTIFY);
191 }
Botan::WARNING
Definition: tls_magic.h:58
Botan::CLOSE_NOTIFY
Definition: tls_magic.h:63
Botan::TLS_Server::close
void close()
Definition: tls_server.cpp:188

## ◆ is_closed()

bool Botan::TLS_Server::is_closed | ( |  | ) | const

Definition at line 178 of file tls_server.cpp.

179 {
180 if(!active)
181 return true;
182 return false;
183 }

## ◆ peer_cert_chain()

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

Implements Botan::TLS_Connection.

Definition at line 137 of file tls_server.cpp.

138 {
139 return peer_certs;
140 }

## ◆ 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_Server::read | ( | byte | buf[],
|  | size_t | buf_len
| ) |  |
| virtual

Implements Botan::TLS_Connection.

Definition at line 156 of file tls_server.cpp.

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

157 {
158 if(!active)
159 throw Internal_Error("TLS_Server::read called while closed");
160
161 writer.flush();
162
163 while(read_buf.size() == 0)
164 {
165 state_machine();
166 if(active == false)
167 break;
168 }
169
170 size_t got = std::min<size_t>(read_buf.size(), length);
171 read_buf.read(out, got);
172 return got;
173 }
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

## ◆ requested_hostname()

std::string Botan::TLS_Server::requested_hostname | ( |  | ) | const
| inline

Definition at line 29 of file tls_server.h.

30 { return client_requested_hostname; }

## ◆ 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_Server::write | ( | const byte | buf[],
|  | size_t | buf_len
| ) |  |
| virtual

Implements Botan::TLS_Connection.

Definition at line 145 of file tls_server.cpp.

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

146 {
147 if(!active)
148 throw Internal_Error("TLS_Server::write called while closed");
149
150 writer.send(APPLICATION_DATA, buf, length);
151 }
Botan::APPLICATION_DATA
Definition: tls_magic.h:37
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_server.h
- src/ssl/tls_server.cpp