]> WPIA git - cassiopeia.git/blobdiff - src/apps/client.cpp
Merge "chg: rename package name and all references to it"
[cassiopeia.git] / src / apps / client.cpp
index 9dea0a88b5f06ebf438377f86003f454db54f904..87447431665c9c31340aedc737d734f3e5d36648 100644 (file)
@@ -16,6 +16,7 @@
 #include "io/bios.h"
 #include "io/slipBio.h"
 #include "config.h"
+#include <internal/bio.h>
 
 #ifdef NO_DAEMON
 #define DAEMON false
@@ -45,8 +46,8 @@ void checkCRLs( std::shared_ptr<Signer> sign ) {
         try {
             std::vector<std::string> serials;
             std::pair<std::shared_ptr<CRL>, std::string> rev = sign->revoke( x.second, serials );
-        } catch( const char* c ) {
-            logger::error( "Exception: ", c );
+        } catch( const std::exception &e ) {
+            logger::error( "Exception: ", e.what() );
         }
     }
 }
@@ -65,7 +66,7 @@ int main( int argc, const char* argv[] ) {
     std::string path;
 
 #ifdef NDEBUG
-    path = "/etc/cacert/cassiopeia/cassiopeia.conf";
+    path = "/etc/wpia/cassiopeia/cassiopeia.conf";
 #else
     path = "config.txt";
 #endif
@@ -81,7 +82,8 @@ int main( int argc, const char* argv[] ) {
     }
     std::shared_ptr<JobProvider> jp = std::make_shared<PostgresJobProvider>( sqlHost, sqlUser, sqlPass, sqlDB );
     std::shared_ptr<BIO> b = openSerial( serialPath );
-    std::shared_ptr<BIO> slip1( BIO_new( toBio<SlipBIO>() ), BIO_free );
+    std::shared_ptr<BIO_METHOD> m( toBio<SlipBIO>(), BIO_meth_free);
+    std::shared_ptr<BIO> slip1( BIO_new( m.get() ), BIO_free );
     static_cast<SlipBIO*>( slip1->ptr )->setTarget( std::make_shared<OpensslBIOWrapper>( b ), false );
     auto sign = std::make_shared<RemoteSigner>( slip1, generateSSLContext( false ) );
     // std::shared_ptr<Signer> sign( new SimpleOpensslSigner() );
@@ -118,7 +120,6 @@ int main( int argc, const char* argv[] ) {
                 logger::errorf ( "Exception while fetchJob: %s", e.what() );
            }
             if( !job ) {
-                logger::note( "Nothing to work on." );
                 sleep( 5 );
                 continue;
             }
@@ -166,8 +167,9 @@ int main( int argc, const char* argv[] ) {
                         continue;
                     }
 
-                    logger::note( "FINE: CERTIFICATE LOG:\n", res->log );
-                    logger::note( "FINE: CERTIFICATE:\n", res->certificate );
+                    logger::note( "FINE: CERTIFICATE LOG:\n", res->log,
+                                 "FINE: CERTIFICATE:\n", res->certificate );
+
                     std::string fn = writeBackFile( job->target.c_str(), res->certificate, keyDir );
 
                     if( fn.empty() ) {
@@ -185,18 +187,14 @@ int main( int argc, const char* argv[] ) {
                     }
 
                     continue;
-                } catch( const char* c ) {
-                    logger::error( "ERROR: ", c );
-                } catch( std::string& c ) {
-                    logger::error( "ERROR: ", c );
+                } catch( std::exception& c ) {
+                    logger::error( "ERROR: ", c.what() );
                 }
 
                 try {
                     jp->failJob( job );
-                } catch( const char* c ) {
-                    logger::error( "ERROR: ", c );
-                } catch( std::string& c ) {
-                    logger::error( "ERROR: ", c );
+                } catch( std::exception& c ) {
+                    logger::error( "ERROR: ", c.what() );
                 }
             } else if( job->task == "revoke" ) {
                 try {
@@ -212,10 +210,8 @@ int main( int argc, const char* argv[] ) {
 
                     jp->writeBackRevocation( job, timeToString( time ) );
                     jp->finishJob( job );
-                } catch( const char* c ) {
-                    logger::error( "Exception: ", c );
-                } catch( const std::string& c ) {
-                    logger::error( "Exception: ", c );
+                } catch( const std::exception& c ) {
+                    logger::error( "Exception: ", c.what() );
                 }
             } else {
                 logger::errorf( "Unknown job type (\"%s\")", job->task );
@@ -225,10 +221,6 @@ int main( int argc, const char* argv[] ) {
             if( !DAEMON || once ) {
                 return 0;
             }
-       } catch( const char* c ) {
-            logger::error( "Exception: ", c );
-        } catch( const std::string& c ) {
-            logger::error( "Exception: ", c );
         } catch ( std::exception &e ){
             logger::errorf ( "std::exception in mainloop: %s", e.what() );
         }