Commit a87dba71 authored by Fred Qiu's avatar Fred Qiu Committed by Facebook GitHub Bot

Rename alpn option in folly/openssl

Summary:
Renamed alpn option from requireAlpnIfClientSupports to
alpnAllowMismatch.

Reviewed By: knekritz

Differential Revision: D29968118

fbshipit-source-id: bb515efec22520e52444530a2de2b3835691c26c
parent 24821079
...@@ -590,7 +590,7 @@ int SSLContext::alpnSelectCallback( ...@@ -590,7 +590,7 @@ int SSLContext::alpnSelectCallback(
item.length, item.length,
in, in,
inlen) != OPENSSL_NPN_NEGOTIATED) { inlen) != OPENSSL_NPN_NEGOTIATED) {
if (context->getRequireAlpnIfClientSupports()) { if (!context->getAlpnAllowMismatch()) {
return SSL_TLSEXT_ERR_ALERT_FATAL; return SSL_TLSEXT_ERR_ALERT_FATAL;
} else { } else {
return SSL_TLSEXT_ERR_NOACK; return SSL_TLSEXT_ERR_NOACK;
......
...@@ -533,12 +533,10 @@ class SSLContext { ...@@ -533,12 +533,10 @@ class SSLContext {
void unsetNextProtocols(); void unsetNextProtocols();
void deleteNextProtocolsStrings(); void deleteNextProtocolsStrings();
bool getRequireAlpnIfClientSupports() const { bool getAlpnAllowMismatch() const { return alpnAllowMismatch_; }
return requireAlpnIfClientSupports_;
}
void setRequireAlpnIfClientSupports(bool require) { void setAlpnAllowMismatch(bool allowMismatch) {
requireAlpnIfClientSupports_ = require; alpnAllowMismatch_ = allowMismatch;
} }
#endif // FOLLY_OPENSSL_HAS_ALPN #endif // FOLLY_OPENSSL_HAS_ALPN
...@@ -685,7 +683,7 @@ class SSLContext { ...@@ -685,7 +683,7 @@ class SSLContext {
size_t pickNextProtocols(); size_t pickNextProtocols();
bool requireAlpnIfClientSupports_{false}; bool alpnAllowMismatch_{true};
#endif // FOLLY_OPENSSL_HAS_ALPN #endif // FOLLY_OPENSSL_HAS_ALPN
......
...@@ -587,10 +587,10 @@ TEST_F(NextProtocolTest, RandomizedAlpnTest) { ...@@ -587,10 +587,10 @@ TEST_F(NextProtocolTest, RandomizedAlpnTest) {
EXPECT_EQ(selectedProtocols.size(), 2); EXPECT_EQ(selectedProtocols.size(), 2);
} }
TEST_F(NextProtocolTest, AlpnRequiredIfClientSupportsTestNoClientProtocol) { TEST_F(NextProtocolTest, AlpnNotAllowMismatchNoClientProtocol) {
clientCtx->setAdvertisedNextProtocols({}); clientCtx->setAdvertisedNextProtocols({});
serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"}); serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"});
serverCtx->setRequireAlpnIfClientSupports(true); serverCtx->setAlpnAllowMismatch(false);
connect(); connect();
...@@ -598,20 +598,20 @@ TEST_F(NextProtocolTest, AlpnRequiredIfClientSupportsTestNoClientProtocol) { ...@@ -598,20 +598,20 @@ TEST_F(NextProtocolTest, AlpnRequiredIfClientSupportsTestNoClientProtocol) {
expectNoProtocol(); expectNoProtocol();
} }
TEST_F(NextProtocolTest, AlpnRequiredIfClientSupportsTestOverlap) { TEST_F(NextProtocolTest, AlpnNotAllowMismatchWithOverlap) {
clientCtx->setAdvertisedNextProtocols({"blub", "baz"}); clientCtx->setAdvertisedNextProtocols({"blub", "baz"});
serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"}); serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"});
serverCtx->setRequireAlpnIfClientSupports(true); serverCtx->setAlpnAllowMismatch(false);
connect(); connect();
expectProtocol("baz"); expectProtocol("baz");
} }
TEST_F(NextProtocolTest, AlpnRequiredIfClientSupportsTestNoOverlap) { TEST_F(NextProtocolTest, AlpnNotAllowMismatchWithoutOverlap) {
clientCtx->setAdvertisedNextProtocols({"blub"}); clientCtx->setAdvertisedNextProtocols({"blub"});
serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"}); serverCtx->setAdvertisedNextProtocols({"foo", "bar", "baz"});
serverCtx->setRequireAlpnIfClientSupports(true); serverCtx->setAlpnAllowMismatch(false);
connect(); connect();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment