X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fconfig.cpp;h=a58cc82878acabf16190dcc212bb27e2a617b8f3;hb=25b4018f92fc3245ad91ff6c0d12fc5dacc3cadd;hp=495231c8a377f1c9c5c5e86ed6ce3a0bfb4411de;hpb=3c27aae8d1bfbf441c25b273d328d0859022ed60;p=cassiopeia.git diff --git a/src/config.cpp b/src/config.cpp index 495231c..a58cc82 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -13,15 +13,17 @@ std::unordered_map profiles; std::unordered_map> CAs; std::string sqlHost, sqlUser, sqlPass, sqlDB; std::string serialPath; +std::string crlPrefix; +std::string crtPrefix; std::shared_ptr> parseConf( std::string path ) { - std::shared_ptr> map( new std::unordered_map() ); + auto map = std::make_shared>(); std::ifstream config; config.open( path ); if( !config.is_open() ) { logger::notef( "Where is \"%s\"?", path ); - throw "Config missing"; + throw std::runtime_error( "Config missing" ); } std::string line1; @@ -51,8 +53,8 @@ std::shared_ptr> parseConf( std::st int parseProfiles() { CAs = std::unordered_map>(); - DIR* dp; - struct dirent* ep; + DIR *dp; + struct dirent *ep; dp = opendir( "profiles" ); if( dp == NULL ) { @@ -91,21 +93,25 @@ 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; } if( CAs.find( caName ) == CAs.end() ) { - std::shared_ptr ca( new CAConfig( caName ) ); + auto ca = std::make_shared( caName ); CAs.emplace( caName, ca ); } @@ -115,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 ); @@ -138,6 +144,8 @@ int parseConfig( std::string path ) { sqlPass = masterConf->at( "sql.password" ); sqlDB = masterConf->at( "sql.database" ); serialPath = masterConf->at( "serialPath" ); + crlPrefix = masterConf->at( "crlPrefix" ); + crtPrefix = masterConf->at( "crtPrefix" ); if( keyDir == "" ) { logger::error( "Missing config property key.directory" );