X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fio%2FrecordHandler.cpp;h=2d58be0b7d1e195e62350ebaadd4cc9191074b4f;hb=eac5817fe5ed5052599bbfb1ab3f6ade426010d0;hp=87b11763342f65a4c89b61ae09cb9b49ab4924fa;hpb=709700dfbbeb5bf8aee1f5a1966f0192d783ae03;p=cassiopeia.git diff --git a/src/io/recordHandler.cpp b/src/io/recordHandler.cpp index 87b1176..2d58be0 100644 --- a/src/io/recordHandler.cpp +++ b/src/io/recordHandler.cpp @@ -72,16 +72,7 @@ public: } void work() { - std::vector buffer( 2048 ); - int res = io->read( buffer.data(), buffer.size() ); - - if( res <= 0 ) { - logger::error( "Stream error, resetting SSL" ); - parent->reset(); - return; - } - - std::string content( buffer.data(), res ); + std::string content = io->readLine(); try { RecordHeader head; @@ -175,9 +166,12 @@ public: respondCommand( RecordHeader::SignerResult::CERTIFICATE, result->certificate ); } + logger::note( "Shutting down SSL" ); if( !SSL_shutdown( ssl.get() ) && !SSL_shutdown( ssl.get() ) ) { logger::warn( "ERROR: SSL shutdown failed." ); } + io->ctrl( BIO_CTRL_FLUSH, 0, NULL ); + logger::note( "Shutted down SSL" ); parent->reset(); // Connection ended @@ -207,10 +201,13 @@ public: auto ca = CAs.at( data ); CRL c( ca->path + "/ca.crl" ); respondCommand( RecordHeader::SignerResult::FULL_CRL, c.toString() ); - + + logger::note( "Shutting down SSL" ); if( !SSL_shutdown( ssl.get() ) && !SSL_shutdown( ssl.get() ) ) { logger::error( "ERROR: SSL shutdown failed." ); } + io->ctrl( BIO_CTRL_FLUSH, 0, NULL ); + logger::note( "Shutted down SSL" ); parent->reset(); // Connection ended } @@ -232,9 +229,13 @@ void DefaultRecordHandler::reset() { void DefaultRecordHandler::handle() { if( !currentSession ) { + (void) BIO_reset( bio.get() ); logger::note( "New session allocated." ); currentSession = std::make_shared( this, signer, ctx, bio ); } - - currentSession->work(); + try { + currentSession->work(); + } catch( EOFException e ){ + reset(); + } }