using folly::AsyncSocketException;
using folly::AsyncSSLSocket;
using folly::Optional;
+using folly::SSLContext;
// We have one single dummy SSL context so that we can implement attach
// and detach methods in a thread safe fashion without modifying opnessl.
}
}
-void AsyncSSLSocket::getSelectedNextProtocol(const unsigned char** protoName,
- unsigned* protoLen) const {
- if (!getSelectedNextProtocolNoThrow(protoName, protoLen)) {
+void AsyncSSLSocket::getSelectedNextProtocol(
+ const unsigned char** protoName,
+ unsigned* protoLen,
+ SSLContext::NextProtocolType* protoType) const {
+ if (!getSelectedNextProtocolNoThrow(protoName, protoLen, protoType)) {
throw AsyncSocketException(AsyncSocketException::NOT_SUPPORTED,
"NPN not supported");
}
}
bool AsyncSSLSocket::getSelectedNextProtocolNoThrow(
- const unsigned char** protoName,
- unsigned* protoLen) const {
+ const unsigned char** protoName,
+ unsigned* protoLen,
+ SSLContext::NextProtocolType* protoType) const {
*protoName = nullptr;
*protoLen = 0;
+#if OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined(OPENSSL_NO_TLSEXT)
+ SSL_get0_alpn_selected(ssl_, protoName, protoLen);
+ if (*protoLen > 0) {
+ if (protoType) {
+ *protoType = SSLContext::NextProtocolType::ALPN;
+ }
+ return true;
+ }
+#endif
#ifdef OPENSSL_NPN_NEGOTIATED
SSL_get0_next_proto_negotiated(ssl_, protoName, protoLen);
+ if (protoType) {
+ *protoType = SSLContext::NextProtocolType::NPN;
+ }
return true;
#else
return false;