]> WPIA git - cassiopeia.git/blobdiff - src/config.cpp
fix: Ambiguity when compiling
[cassiopeia.git] / src / config.cpp
index b746bad11a88049338853537be38250c1297bb6a..ad3c1375963a16602d07611b62bc7ff502e31606 100644 (file)
@@ -87,14 +87,32 @@ int parseProfiles() {
         prof.id = std::stoi( id );
         prof.eku = map->at( "eku" );
         prof.ku = map->at( "ku" );
-
-        if( CAs.find( map->at( "ca" ) ) == CAs.end() ) {
-            std::shared_ptr<CAConfig> ca( new CAConfig( map->at( "ca" ) ) );
-            CAs.emplace( map->at( "ca" ), ca );
+        prof.maxValidity = std::stoi( map->at( "days" ) ) * /* DAYS */24 * 60 * 60;
+
+        std::string cas = map->at( "ca" );
+
+        DIR *dir;
+        struct dirent *ent;
+        if ((dir = opendir ("ca")) != NULL) {
+            while ((ent = readdir (dir)) != NULL) {
+                std::string caName = std::string(ent->d_name);
+                if( caName.find( cas ) != 0 ){
+                    continue;
+                }
+
+                if( CAs.find( caName ) == CAs.end() ) {
+                    std::shared_ptr<CAConfig> ca( new CAConfig( caName ) );
+                    CAs.emplace( caName, ca );
+                }
+
+                prof.ca.push_back( CAs.at( caName ) );
+                std::cout << "Adding CA: " << caName << std::endl;
+            }
+            closedir (dir);
+        } else {
+            throw "Directory with CAConfigs not found";
         }
 
-        prof.ca = CAs.at( map->at( "ca" ) );
-
         profiles.emplace( profileName, prof );
         std::cout << "Profile: " << profileName << " up and running." << std::endl;
     }