X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fconfig.cpp;h=ad3c1375963a16602d07611b62bc7ff502e31606;hb=51d4000dfb0ae0c571084c21a070fa1dd020d91c;hp=e88ec2bee52e3331a9c67ea13777964832826c41;hpb=56358cbe81dd0d11267a06133ce227c2c53f10f7;p=cassiopeia.git diff --git a/src/config.cpp b/src/config.cpp index e88ec2b..ad3c137 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -87,29 +87,30 @@ int parseProfiles() { prof.id = std::stoi( id ); prof.eku = map->at( "eku" ); prof.ku = map->at( "ku" ); + prof.maxValidity = std::stoi( map->at( "days" ) ) * /* DAYS */24 * 60 * 60; std::string cas = map->at( "ca" ); - for( size_t pos = 0; pos != std::string::npos; ) { - size_t end = cas.find( ",", pos ); - std::string sub; - - if( end == std::string::npos ) { - sub = cas.substr( pos ); - } else { - sub = cas.substr( pos, end - pos ); - end++; - } - - pos = end; - - if( CAs.find( sub ) == CAs.end() ) { - std::shared_ptr ca( new CAConfig( sub ) ); - CAs.emplace( sub, 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 ca( new CAConfig( caName ) ); + CAs.emplace( caName, ca ); + } + + prof.ca.push_back( CAs.at( caName ) ); + std::cout << "Adding CA: " << caName << std::endl; } - - prof.ca.push_back( CAs.at( sub ) ); - + closedir (dir); + } else { + throw "Directory with CAConfigs not found"; } profiles.emplace( profileName, prof );