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

Method _ssl_write_buffer

src/iocore/net/SSLNetVConnection.cc:2240–2292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2238}
2239
2240ssl_error_t
2241SSLNetVConnection::_ssl_write_buffer(const void *buf, int64_t nbytes, int64_t &nwritten)
2242{
2243 nwritten = 0;
2244
2245 if (unlikely(nbytes == 0)) {
2246 return SSL_ERROR_NONE;
2247 }
2248
2249 int ret;
2250 // If SSL_write_early_data is available, it's probably OpenSSL,
2251 // and SSL_is_init_finished should be available.
2252 // If SSL_write_early_data is unavailable, its' probably BoringSSL,
2253 // and we can use SSL_write to send early data.
2254#if TS_HAS_TLS_EARLY_DATA
2255 if (SSL_version(ssl) >= TLS1_3_VERSION) {
2256#ifdef HAVE_SSL_WRITE_EARLY_DATA
2257 if (SSL_is_init_finished(ssl)) {
2258#endif
2259 ret = SSL_write(ssl, buf, static_cast<int>(nbytes));
2260#ifdef HAVE_SSL_WRITE_EARLY_DATA
2261 } else {
2262 size_t nwrite;
2263 ret = SSL_write_early_data(ssl, buf, static_cast<size_t>(nbytes), &nwrite);
2264 if (ret == 1) {
2265 ret = nwrite;
2266 }
2267 }
2268#endif
2269 } else {
2270 ret = SSL_write(ssl, buf, static_cast<int>(nbytes));
2271 }
2272#else
2273 ret = SSL_write(ssl, buf, static_cast<int>(nbytes));
2274#endif
2275
2276 if (ret > 0) {
2277 nwritten = ret;
2278 BIO *bio = SSL_get_wbio(ssl);
2279 if (bio != nullptr) {
2280 (void)BIO_flush(bio);
2281 }
2282 return SSL_ERROR_NONE;
2283 }
2284 int ssl_error = SSL_get_error(ssl, ret);
2285 if (ssl_error == SSL_ERROR_SSL && dbg_ctl_ssl_error_write.on()) {
2286 char tempbuf[512];
2287 unsigned long e = ERR_peek_last_error();
2288 ERR_error_string_n(e, tempbuf, sizeof(tempbuf));
2289 DbgPrint(dbg_ctl_ssl_error_write, "SSL write returned %d, ssl_error=%d, ERR_get_error=%ld (%s)", ret, ssl_error, e, tempbuf);
2290 }
2291 return ssl_error;
2292}
2293
2294ssl_error_t
2295SSLNetVConnection::_ssl_read_buffer(void *buf, int64_t nbytes, int64_t &nread)

Callers 1

load_buffer_and_writeMethod · 0.95

Calls 1

onMethod · 0.45

Tested by

no test coverage detected