8 std::vector<Profile> profiles;
9 std::string sqlHost, sqlUser, sqlPass, sqlDB;
11 int parseConfig( std::string path ) {
15 if( !config.is_open() ) {
16 std::cerr << "config missing" << std::endl;
22 while( std::getline( config, line1 ) ) {
23 if( line1[0] == '#' || line1.size() == 0 ) {
27 int splitter = line1.find( "=" );
29 if( splitter == -1 ) {
30 std::cerr << "Ignoring malformed config line: " << line1 << std::endl;
34 std::string key = line1.substr( 0, splitter );
35 std::string value = line1.substr( splitter + 1 );
37 if( key == "key.directory" ) {
40 } else if( key == "sql.host" ) {
42 } else if( key == "sql.user" ) {
44 } else if( key == "sql.password" ) {
46 } else if( key == "sql.database" ) {
50 if( key.compare( 0, 8, "profile." ) == 0 ) {
51 int numE = key.find( ".", 9 );
54 std::cout << "invalid line: " << line1 << std::endl;
58 unsigned int i = atoi( key.substr( 8, numE - 8 ).c_str() );
59 std::string rest = key.substr( numE + 1 );
61 if( i + 1 > profiles.size() ) {
62 profiles.resize( i + 1 );
66 profiles[i].key = value;
67 } else if( rest == "cert" ) {
68 profiles[i].cert = value;
69 } else if( rest == "ku" ) {
70 profiles[i].ku = value;
71 } else if( rest == "eku" ) {
72 profiles[i].eku = value;
74 std::cout << "invalid line: " << line1 << std::endl;
80 for( auto& prof : profiles ) {
81 if( prof.cert != "" && prof.key != "" ) {
82 std::cout << "Loading profile... " << std::endl;
83 prof.ca = loadX509FromFile( prof.cert );
84 prof.caKey = loadPkeyFromFile( prof.key );
88 std::cout << profiles.size() << " profiles loaded." << std::endl;
91 std::cerr << "Missing config property key.directory" << std::endl;