- for( auto& prof : profiles ) {
- if( prof.cert != "" && prof.key != "" ) {
- std::cout << "Loading profile... " << std::endl;
- prof.ca = loadX509FromFile( prof.cert );
- prof.caKey = loadPkeyFromFile( prof.key );
+ auto map = parseConf( std::string( "profiles/" ) + profileName );
+
+ profileName = profileName.substr( 0, profileName.size() - 4 );
+
+ Profile prof;
+ 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" );
+
+ 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 ) );
+ logger::note( "Adding CA: ", caName );
+ }
+
+ closedir( dir );
+ } else {
+ throw "Directory with CAConfigs not found";