if you get an error from connect see note at top of README
| 246 | |
| 247 | // if you get an error from connect see note at top of README |
| 248 | int 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; |
no test coverage detected