]> WPIA git - cassiopeia.git/blobdiff - src/config.cpp
add: signing of OCSP certificates
[cassiopeia.git] / src / config.cpp
index 4440d09f267e4fc81cf2cfc67f506aac5b21dd6b..a58cc82878acabf16190dcc212bb27e2a617b8f3 100644 (file)
@@ -23,7 +23,7 @@ std::shared_ptr<std::unordered_map<std::string, std::string>> parseConf( std::st
 
     if( !config.is_open() ) {
         logger::notef( "Where is \"%s\"?", path );
-        throw "Config missing";
+        throw std::runtime_error( "Config missing" );
     }
 
     std::string line1;
@@ -53,8 +53,8 @@ std::shared_ptr<std::unordered_map<std::string, std::string>> parseConf( std::st
 int parseProfiles() {
     CAs = std::unordered_map<std::string, std::shared_ptr<CAConfig>>();
 
-    DIRdp;
-    struct direntep;
+    DIR *dp;
+    struct dirent *ep;
     dp = opendir( "profiles" );
 
     if( dp == NULL ) {
@@ -93,16 +93,20 @@ int parseProfiles() {
         prof.ku = map->at( "ku" );
         prof.maxValidity = std::stoi( map->at( "days" ) ) * /* DAYS */24 * 60 * 60;
 
-        std::string cas = map->at( "ca" );
 
-        DIR* dir;
-        struct dirent* ent;
+        DIR *dir;
+        struct dirent *ent;
+
+        if( profileName == "0100-ocsp" ) {
+            //This profile does not have a specific CA. The concrete CA has to be set in each request.
+        } else if( ( dir = opendir( "ca" ) ) != NULL ) {
+            std::string cas = map->at( "ca" );
+            std::string toFind = cas + "_";
 
-        if( ( dir = opendir( "ca" ) ) != NULL ) {
             while( ( ent = readdir( dir ) ) != NULL ) {
                 std::string caName = std::string( ent->d_name );
 
-                if( caName.find( cas ) != 0 ) {
+                if( caName.find( toFind ) != 0 ) {
                     continue;
                 }
 
@@ -117,7 +121,7 @@ int parseProfiles() {
 
             closedir( dir );
         } else {
-            throw "Directory with CAConfigs not found";
+            throw std::runtime_error( "Directory with CAConfigs not found" );
         }
 
         profiles.emplace( profileName, prof );