X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fapps%2Fclient.cpp;h=f044c2b84a43d42394ddf457f4b33aad3f06726d;hb=da9f337a893bd317460118f89efa83a3427f797f;hp=c3a011531306e35685af4a7fc62413cea0b3f958;hpb=6121035a7d8ea738bc89c2de8e6602fb1099b0e2;p=cassiopeia.git diff --git a/src/apps/client.cpp b/src/apps/client.cpp index c3a0115..f044c2b 100644 --- a/src/apps/client.cpp +++ b/src/apps/client.cpp @@ -46,13 +46,13 @@ void checkCRLs( std::shared_ptr sign ) { try { std::vector serials; std::pair, std::string> rev = sign->revoke( x.second, serials ); - } catch( const std::exception &e ) { + } catch( const std::exception& e ) { logger::error( "Exception: ", e.what() ); } } } -int main( int argc, const char* argv[] ) { +int main( int argc, const char *argv[] ) { bool once = false; bool resetOnly = false; @@ -86,7 +86,7 @@ int main( int argc, const char* argv[] ) { std::shared_ptr b = openSerial( serialPath ); std::shared_ptr m( toBio(), BIO_meth_free ); std::shared_ptr slip1( BIO_new( m.get() ), BIO_free ); - static_cast( slip1->ptr )->setTarget( std::make_shared( b ), false ); + static_cast( slip1->ptr )->setTarget( std::make_shared( b ), false ); auto sign = std::make_shared( slip1, generateSSLContext( false ) ); // std::shared_ptr sign( new SimpleOpensslSigner() ); @@ -119,7 +119,7 @@ int main( int argc, const char* argv[] ) { try { job = jp->fetchJob(); - } catch ( std::exception &e ){ + } catch( std::exception& e ) { logger::errorf( "Exception while fetchJob: %s", e.what() ); } @@ -140,6 +140,13 @@ int main( int argc, const char* argv[] ) { if( job->task == "sign" ) { try { std::shared_ptr cert = jp->fetchTBSCert( job ); + + if( !cert ) { + logger::error( "Unable to load CSR" ); + jp->failJob( job ); + continue; + } + cert->wishFrom = job->from; cert->wishTo = job->to; logger::note( "INFO: Message Digest: ", cert->md ); @@ -153,12 +160,6 @@ int main( int argc, const char* argv[] ) { logger::notef( "INFO: AVA %s: %s", AVA->name, AVA->value ); } - if( !cert ) { - logger::error( "Unable to load CSR" ); - jp->failJob( job ); - continue; - } - logger::notef( "FINE: Found the CSR at '%s'", cert->csr ); cert->csr_content = readFile( keyDir + "/../" + cert->csr ); logger::note( "FINE: CSR content:\n", cert->csr_content ); @@ -209,7 +210,7 @@ int main( int argc, const char* argv[] ) { logger::note( "revoking" ); std::pair, std::string> rev = sign->revoke( CAs.at( data.second ), serials ); std::string date = rev.second; - const unsigned char* pos = ( const unsigned char* ) date.data(); + const unsigned char *pos = ( const unsigned char * ) date.data(); std::shared_ptr time( d2i_ASN1_TIME( NULL, &pos, date.size() ), ASN1_TIME_free ); jp->writeBackRevocation( job, timeToString( time ) ); @@ -225,7 +226,7 @@ int main( int argc, const char* argv[] ) { if( !DAEMON || once ) { return 0; } - } catch ( std::exception &e ){ + } catch( std::exception& e ) { logger::errorf( "std::exception in mainloop: %s", e.what() ); }