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

Method _ssl_connect

src/iocore/net/SSLNetVConnection.cc:2192–2238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2190}
2191
2192ssl_error_t
2193SSLNetVConnection::_ssl_connect()
2194{
2195 ERR_clear_error();
2196
2197 SSL_SESSION *sess = SSL_get_session(ssl);
2198 if (first_ssl_connect) {
2199 first_ssl_connect = false;
2200 if (!sess && SSLConfigParams::origin_session_cache == 1 && SSLConfigParams::origin_session_cache_size > 0) {
2201 std::string sni_addr = get_sni_addr(ssl);
2202 if (!sni_addr.empty()) {
2203 std::string lookup_key;
2204 swoc::bwprint(lookup_key, "{}:{}:{}", sni_addr.c_str(), SSL_get_SSL_CTX(ssl), get_verify_str(ssl));
2205
2206 Dbg(dbg_ctl_ssl_origin_session_cache, "origin session cache lookup key = %s", lookup_key.c_str());
2207
2208 std::shared_ptr<SSL_SESSION> shared_sess = this->getOriginSession(lookup_key);
2209
2210 if (shared_sess && SSL_set_session(ssl, shared_sess.get())) {
2211 // Keep a reference of this shared pointer in the connection
2212 this->client_sess = shared_sess;
2213 }
2214 }
2215 }
2216 }
2217
2218 int ret = SSL_connect(ssl);
2219
2220 if (ret > 0) {
2221 if (SSL_session_reused(ssl)) {
2222 Metrics::Counter::increment(ssl_rsb.origin_session_reused_count);
2223 Dbg(dbg_ctl_ssl_origin_session_cache, "reused session to origin server");
2224 } else {
2225 Dbg(dbg_ctl_ssl_origin_session_cache, "new session to origin server");
2226 }
2227 return SSL_ERROR_NONE;
2228 }
2229 int ssl_error = SSL_get_error(ssl, ret);
2230 if (ssl_error == SSL_ERROR_SSL && dbg_ctl_ssl_error_connect.on()) {
2231 char buf[512];
2232 unsigned long e = ERR_peek_last_error();
2233 ERR_error_string_n(e, buf, sizeof(buf));
2234 DbgPrint(dbg_ctl_ssl_error_connect, "SSL connect returned %d, ssl_error=%d, ERR_get_error=%ld (%s)", ret, ssl_error, e, buf);
2235 }
2236
2237 return ssl_error;
2238}
2239
2240ssl_error_t
2241SSLNetVConnection::_ssl_write_buffer(const void *buf, int64_t nbytes, int64_t &nwritten)

Callers 1

Calls 8

get_sni_addrFunction · 0.85
get_verify_strFunction · 0.85
incrementFunction · 0.85
getOriginSessionMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45
getMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected