| 516 | } |
| 517 | |
| 518 | static int SetServerALPNCallback(SSL_CTX* ssl_ctx, const std::string* alpns) { |
| 519 | if (ssl_ctx == nullptr) { |
| 520 | LOG(ERROR) << "Fail to set server ALPN callback, ssl_ctx is nullptr."; |
| 521 | return -1; |
| 522 | } |
| 523 | |
| 524 | // Server set alpn callback when openssl version is more than 1.0.2 |
| 525 | #if (OPENSSL_VERSION_NUMBER >= SSL_VERSION_NUMBER(1, 0, 2)) |
| 526 | SSL_CTX_set_alpn_select_cb(ssl_ctx, ServerALPNCallback, |
| 527 | const_cast<std::string*>(alpns)); |
| 528 | #else |
| 529 | LOG(WARNING) << "OpenSSL version=" << OPENSSL_VERSION_STR |
| 530 | << " is lower than 1.0.2, ignore server alpn."; |
| 531 | #endif |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | SSL_CTX* CreateClientSSLContext(const ChannelSSLOptions& options) { |
| 536 | std::unique_ptr<SSL_CTX, FreeSSLCTX> ssl_ctx( |
no outgoing calls
no test coverage detected