MCPcopy Create free account
hub / github.com/apache/impala / DoNegotiationSide

Function DoNegotiationSide

security/tls_socket-test.cc:79–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77};
78
79Status DoNegotiationSide(Socket* sock, TlsHandshake* tls, const char* side) {
80 tls->set_verification_mode(TlsVerificationMode::VERIFY_NONE);
81
82 bool done = false;
83 string received;
84 while (!done) {
85 string to_send;
86 Status s = tls->Continue(received, &to_send);
87 if (s.ok()) {
88 done = true;
89 } else if (!s.IsIncomplete()) {
90 RETURN_NOT_OK_PREPEND(s, "unexpected tls error");
91 }
92 if (!to_send.empty()) {
93 size_t nwritten;
94 auto deadline = MonoTime::Now() + MonoDelta::FromSeconds(10);
95 RETURN_NOT_OK_PREPEND(sock->BlockingWrite(
96 reinterpret_cast<const uint8_t*>(to_send.data()),
97 to_send.size(), &nwritten, deadline),
98 "error sending");
99 }
100
101 if (!done) {
102 uint8_t buf[1024];
103 int32_t n = 0;
104 RETURN_NOT_OK_PREPEND(sock->Recv(buf, arraysize(buf), &n),
105 "error receiving");
106 received = string(reinterpret_cast<char*>(&buf[0]), n);
107 }
108 }
109 LOG(INFO) << side << ": negotiation complete";
110 return Status::OK();
111}
112
113void TlsSocketTest::ConnectClient(const Sockaddr& addr, unique_ptr<Socket>* sock) {
114 unique_ptr<Socket> client_sock(new Socket());

Callers 2

ConnectClientMethod · 0.70
StartMethod · 0.70

Calls 9

OKFunction · 0.85
set_verification_modeMethod · 0.80
ContinueMethod · 0.80
BlockingWriteMethod · 0.80
okMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
RecvMethod · 0.45

Tested by

no test coverage detected