cdjingit commented on code in PR #2102:
URL: https://github.com/apache/brpc/pull/2102#discussion_r1092733973


##########
src/brpc/details/ssl_helper.cpp:
##########
@@ -441,6 +441,42 @@ static int SetSSLOptions(SSL_CTX* ctx, const std::string& 
ciphers,
     return 0;
 }
 
+static int ServerALPNCallback(SSL* ssl,
+        const unsigned char** out, unsigned char* outlen,
+        const unsigned char* in, unsigned int inlen, void* arg) {
+    const std::string* alpns = static_cast<const std::string*>(arg);
+    if (alpns == nullptr) {
+        return SSL_TLSEXT_ERR_NOACK;
+    }
+
+    // Use OpenSSL standard select API.
+    int select_result = SSL_select_next_proto(
+            const_cast<unsigned char**>(out), outlen, 
+            reinterpret_cast<const unsigned char*>(alpns->data()), 
alpns->size(),
+            in, inlen);
+    if (select_result == OPENSSL_NPN_NEGOTIATED) {
+        return SSL_TLSEXT_ERR_OK;
+    }
+    return SSL_TLSEXT_ERR_NOACK; 

Review Comment:
   ```
   return select_result == OPENSSL_NPN_NEGOTIATED ? SSL_TLSEXT_ERR_OK : 
SSL_TLSEXT_ERR_NOACK;



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to