MCPcopy Create free account
hub / github.com/acl-dev/acl / open

Method open

lib_acl_cpp/src/stream/openssl_io.cpp:222–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220#endif
221
222bool openssl_io::open(ACL_VSTREAM* s)
223{
224 if (s == NULL) {
225 logger_error("s null");
226 return false;
227 }
228
229 this->stream_ = s;
230 ++(*refers_);
231
232#ifdef HAS_OPENSSL
233 if (!nblock_ && conf_.is_sockopt_timeout() && s->rw_timeout > 0) {
234 ACL_SOCKET fd = ACL_VSTREAM_SOCK(s);
235
236 if (!set_sock_timeo(fd, SO_RCVTIMEO, s->rw_timeout)) {
237 logger_error("set recv timeout error");
238 return false;
239 }
240
241 if (!set_sock_timeo(fd, SO_SNDTIMEO, s->rw_timeout)) {
242 logger_error("set send timeout error");
243 return false;
244 }
245 }
246
247 SSL_CTX* ctx = conf_.get_ssl_ctx();
248 if (ctx == NULL) {
249 logger_error("The default SSL_CTX in conf_ is null");
250 return false;
251 }
252
253 SSL* ssl = __ssl_new(ctx);
254 openssl_conf::bind(ssl, this);
255
256 if (!__ssl_set_fd(ssl, (int) ACL_VSTREAM_SOCK(s))) {
257 logger_error("SSL_set_fd error");
258 __ssl_free(ssl);
259 return false;
260 }
261
262 if (conf_.is_server_side()) {
263 __ssl_set_accept_state(ssl);
264 } else {
265 if (!sni_host_.empty()) {
266 __ssl_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME,
267 TLSEXT_NAMETYPE_host_name,
268 (void*) sni_host_.c_str());
269 }
270 __ssl_set_connect_state(ssl);
271 }
272
273 ssl_ = ssl;
274
275 if (nblock_) {
276 return true;
277 }
278
279 return handshake();

Callers

nothing calls this directly

Calls 6

set_sock_timeoFunction · 0.85
bindFunction · 0.85
handshakeFunction · 0.85
get_ssl_ctxMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected