| 663 | } |
| 664 | |
| 665 | SSL_CTX* openssl_conf::create_ssl_ctx() |
| 666 | { |
| 667 | #ifdef HAS_OPENSSL |
| 668 | if (status_ != CONF_INIT_OK) { |
| 669 | logger_error("OpenSSL not init , status=%d", (int) status_); |
| 670 | return NULL; |
| 671 | } |
| 672 | |
| 673 | SSL_CTX* ctx = __ssl_ctx_new(__sslv23_method()); |
| 674 | |
| 675 | if (timeout_ > 0) { |
| 676 | __ssl_ctx_set_timeout(ctx, timeout_); |
| 677 | } |
| 678 | |
| 679 | if (server_side_) { |
| 680 | // SSL_CTX_set_tlsext_servername_callback(ctx, sni_callback); |
| 681 | // SSL_CTX_set_tlsext_servername_arg(ctx, this); |
| 682 | |
| 683 | __ssl_ctx_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, |
| 684 | (void (*)(void)) sni_callback); |
| 685 | __ssl_ctx_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG, 0, this); |
| 686 | } |
| 687 | |
| 688 | set_ssl_version(ctx, ver_min_, ver_max_); |
| 689 | |
| 690 | if (ssl_ctx_ == NULL) { |
| 691 | ssl_ctx_ = ctx; |
| 692 | } |
| 693 | |
| 694 | ssl_ctxes_.insert(ctx); |
| 695 | return ctx; |
| 696 | #else |
| 697 | return NULL; |
| 698 | #endif |
| 699 | } |
| 700 | |
| 701 | bool openssl_conf::push_ssl_ctx(SSL_CTX* ctx) |
| 702 | { |
nothing calls this directly
no test coverage detected