MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / SSL_connect

Function SSL_connect

extra/yassl/src/ssl.cpp:248–324  ·  view source on GitHub ↗

if you get an error from connect see note at top of README

Source from the content-addressed store, hash-verified

246
247// if you get an error from connect see note at top of README
248int SSL_connect(SSL* ssl)
249{
250 if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))
251 ssl->SetError(no_error);
252
253 if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {
254
255 ssl->SetError(no_error);
256 ssl->SendWriteBuffered();
257 if (!ssl->GetError())
258 ssl->useStates().UseConnect() =
259 ConnectState(ssl->getStates().GetConnect() + 1);
260 }
261
262 ClientState neededState;
263
264 switch (ssl->getStates().GetConnect()) {
265
266 case CONNECT_BEGIN :
267 sendClientHello(*ssl);
268 if (!ssl->GetError())
269 ssl->useStates().UseConnect() = CLIENT_HELLO_SENT;
270
271 case CLIENT_HELLO_SENT :
272 neededState = ssl->getSecurity().get_resuming() ?
273 serverFinishedComplete : serverHelloDoneComplete;
274 while (ssl->getStates().getClient() < neededState) {
275 if (ssl->GetError()) break;
276 processReply(*ssl);
277 // if resumption failed, reset needed state
278 if (neededState == serverFinishedComplete)
279 if (!ssl->getSecurity().get_resuming())
280 neededState = serverHelloDoneComplete;
281 }
282 if (!ssl->GetError())
283 ssl->useStates().UseConnect() = FIRST_REPLY_DONE;
284
285 case FIRST_REPLY_DONE :
286 if(ssl->getCrypto().get_certManager().sendVerify())
287 sendCertificate(*ssl);
288
289 if (!ssl->getSecurity().get_resuming())
290 sendClientKeyExchange(*ssl);
291
292 if(ssl->getCrypto().get_certManager().sendVerify())
293 sendCertificateVerify(*ssl);
294
295 sendChangeCipher(*ssl);
296 sendFinished(*ssl, client_end);
297 ssl->flushBuffer();
298
299 if (!ssl->GetError())
300 ssl->useStates().UseConnect() = FINISHED_DONE;
301
302 case FINISHED_DONE :
303 if (!ssl->getSecurity().get_resuming())
304 while (ssl->getStates().getClient() < serverFinishedComplete) {
305 if (ssl->GetError()) break;

Callers 5

ConnectMethod · 0.85
SSL_do_handshakeFunction · 0.85
NonBlockingSSL_ConnectFunction · 0.85
client_testFunction · 0.85
echoclient_testFunction · 0.85

Calls 15

YasslErrorEnum · 0.85
ConnectStateEnum · 0.85
sendClientHelloFunction · 0.85
processReplyFunction · 0.85
sendCertificateFunction · 0.85
sendClientKeyExchangeFunction · 0.85
sendCertificateVerifyFunction · 0.85
sendChangeCipherFunction · 0.85
sendFinishedFunction · 0.85
SendWriteBufferedMethod · 0.80
get_resumingMethod · 0.80
sendVerifyMethod · 0.80

Tested by

no test coverage detected