]> WPIA git - cassiopeia.git/commitdiff
fix: check cert before operating on it
authorFelix Dörre <felix@dogcraft.de>
Sun, 9 Apr 2017 17:15:51 +0000 (17:15 +0000)
committerFelix Dörre <felix@dogcraft.de>
Sun, 23 Apr 2017 00:20:19 +0000 (02:20 +0200)
Change-Id: I61c13d2e0e9c62d0833fff08b05bc4ded31ada98

src/apps/client.cpp

index c3a011531306e35685af4a7fc62413cea0b3f958..ceb267767f05a0704c8c1db6aa6990e077106322 100644 (file)
@@ -140,6 +140,12 @@ int main( int argc, const char* argv[] ) {
             if( job->task == "sign" ) {
                 try {
                     std::shared_ptr<TBSCertificate> 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 +159,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 );