MCPcopy Create free account
hub / github.com/apache/trafficserver / _ssl_read_buffer

Method _ssl_read_buffer

src/iocore/net/SSLNetVConnection.cc:2294–2406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2292}
2293
2294ssl_error_t
2295SSLNetVConnection::_ssl_read_buffer(void *buf, int64_t nbytes, int64_t &nread)
2296{
2297 nread = 0;
2298
2299 if (unlikely(nbytes == 0)) {
2300 return SSL_ERROR_NONE;
2301 }
2302 ERR_clear_error();
2303
2304#if TS_HAS_TLS_EARLY_DATA
2305 if (SSL_version(ssl) >= TLS1_3_VERSION) {
2306 int64_t early_data_len = 0;
2307 if (this->_early_data_reader != nullptr) {
2308 early_data_len = this->_early_data_reader->read_avail();
2309 }
2310
2311 if (early_data_len > 0) {
2312 Dbg(dbg_ctl_ssl_early_data, "Reading from early data buffer.");
2313 this->_increment_early_data_len(this->_early_data_reader->read(buf, nbytes < early_data_len ? nbytes : early_data_len));
2314
2315 if (nbytes < early_data_len) {
2316 nread = nbytes;
2317 } else {
2318 nread = early_data_len;
2319 }
2320
2321 return SSL_ERROR_NONE;
2322 }
2323
2324 bool early_data_enabled = this->hints_from_sni.server_max_early_data.has_value() ?
2325 this->hints_from_sni.server_max_early_data.value() > 0 :
2326 SSLConfigParams::server_max_early_data > 0;
2327 if (early_data_enabled && !this->_early_data_finish) {
2328 bool had_error_on_reading_early_data = false;
2329 bool finished_reading_early_data = false;
2330 Dbg(dbg_ctl_ssl_early_data, "More early data to read.");
2331 ssl_error_t ssl_error = SSL_ERROR_NONE;
2332 int ret;
2333#if HAVE_SSL_READ_EARLY_DATA
2334 size_t read_bytes = 0;
2335#else
2336 ssize_t read_bytes = 0;
2337#endif
2338
2339#if HAVE_SSL_READ_EARLY_DATA
2340 ret = SSL_read_early_data(ssl, buf, static_cast<size_t>(nbytes), &read_bytes);
2341 if (ret == SSL_READ_EARLY_DATA_ERROR) {
2342 had_error_on_reading_early_data = true;
2343 ssl_error = SSL_get_error(ssl, ret);
2344 } else if (ret == SSL_READ_EARLY_DATA_FINISH) {
2345 finished_reading_early_data = true;
2346 }
2347#else
2348 // If SSL_read_early_data is unavailable, it's probably OpenSSL,
2349 // and SSL_in_early_data should be available.
2350 if (SSL_in_early_data(ssl)) {
2351 ret = SSL_read(ssl, buf, nbytes);

Callers 1

_ssl_read_from_netMethod · 0.95

Calls 8

incrementFunction · 0.85
read_availMethod · 0.45
readMethod · 0.45
has_valueMethod · 0.45
valueMethod · 0.45
onMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected