proxygen
FizzServer-inl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 namespace fizz {
10 namespace server {
11 
12 template <typename ActionMoveVisitor, typename SM>
15  std::shared_ptr<const FizzServerContext> context,
16  std::shared_ptr<ServerExtensions> extensions) {
17  checkV2Hello_ = context->getVersionFallbackEnabled();
18  this->addProcessingActions(this->machine_.processAccept(
19  this->state_, executor, std::move(context), std::move(extensions)));
20 }
21 
22 template <typename ActionMoveVisitor, typename SM>
24  // If the first data we receive looks like an SSLv2 Client Hello we trigger
25  // fallback immediately. This uses the same check as OpenSSL, and OpenSSL
26  // does not allow extensions in an SSLv2 Client Hello, so this should not
27  // add additional downgrade concerns.
28  if (checkV2Hello_) {
29  if (!this->actionProcessing() &&
30  looksLikeV2ClientHello(this->transportReadBuf_)) {
31  VLOG(3) << "Attempting fallback due to V2 ClientHello";
32  AttemptVersionFallback fallback;
33  fallback.clientHello = this->transportReadBuf_.move();
34  return this->addProcessingActions(detail::actions(
35  [](State& newState) { newState.state() = StateEnum::Error; },
36  std::move(fallback)));
37  }
38  checkV2Hello_ = false;
39  }
40 
41  FizzBase<FizzServer<ActionMoveVisitor, SM>, ActionMoveVisitor, SM>::
42  newTransportData();
43 }
44 
45 template <typename ActionMoveVisitor, typename SM>
48  const Buf& context,
49  uint16_t length) const {
50  if (!this->state_.earlyExporterMasterSecret()) {
51  throw std::runtime_error("early ekm not available");
52  }
53  return Exporter::getEkm(
54  *this->state_.cipher(),
55  (*this->state_.earlyExporterMasterSecret())->coalesce(),
56  label,
57  context ? context->clone() : nullptr,
58  length);
59 }
60 
61 template <typename ActionMoveVisitor, typename SM>
64  actions,
65  [this](folly::Future<Actions>& futureActions) {
66  std::move(futureActions)
67  .then(
69  static_cast<FizzBase<
71  ActionMoveVisitor,
72  SM>*>(this));
73  },
74  [this](Actions& immediateActions) {
75  this->processActions(std::move(immediateActions));
76  });
77 }
78 } // namespace server
79 } // namespace fizz
Actions actions(Args &&...act)
Definition: Actions.h:57
StateEnum state() const
Definition: State.h:69
context
Definition: CMakeCache.txt:563
void processActions(typename StateMachine::CompletedActions actions)
Definition: FizzBase-inl.h:87
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
boost::variant< Actions, folly::Future< Actions >> AsyncActions
Definition: Actions.h:52
void startActions(AsyncActions actions)
bool looksLikeV2ClientHello(const folly::IOBufQueue &queue)
Definition: FizzServer.cpp:14
void accept(folly::Executor *executor, std::shared_ptr< const FizzServerContext > context, std::shared_ptr< ServerExtensions > extensions=nullptr)
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
Definition: Actions.h:16
Actions actions(Args &&...act)
Definition: Actions.h:86
static Buf getEkm(CipherSuite cipher, folly::ByteRange exporterMaster, folly::StringPiece label, Buf context, uint16_t length)
Definition: Exporter.cpp:13
std::unique_ptr< folly::IOBuf > Buf
Definition: Types.h:22
decltype(auto) variant_match(Variant &&variant, Cases &&...cases)
Definition: Overload.h:74
Buf getEarlyEkm(folly::StringPiece label, const Buf &context, uint16_t length) const
std::unique_ptr< folly::IOBuf > clientHello
Definition: Actions.h:27
StringPiece label