8 std::vector<Profile> profiles;
9 std::string sqlHost, sqlUser, sqlPass, sqlDB;
10 std::string serialPath;
12 int parseConfig( std::string path ) {
16 if( !config.is_open() ) {
17 std::cerr << "config missing" << std::endl;
23 while( std::getline( config, line1 ) ) {
24 if( line1[0] == '#' || line1.size() == 0 ) {
28 int splitter = line1.find( "=" );
30 if( splitter == -1 ) {
31 std::cerr << "Ignoring malformed config line: " << line1 << std::endl;
35 std::string key = line1.substr( 0, splitter );
36 std::string value = line1.substr( splitter + 1 );
38 if( key == "key.directory" ) {
41 } else if( key == "sql.host" ) {
43 } else if( key == "sql.user" ) {
45 } else if( key == "sql.password" ) {
47 } else if( key == "sql.database" ) {
49 } else if( key == "serialPath" ) {
51 } else if( key.compare( 0, 8, "profile." ) == 0 ) {
52 int numE = key.find( ".", 9 );
55 std::cout << "invalid line: " << line1 << std::endl;
59 unsigned int i = atoi( key.substr( 8, numE - 8 ).c_str() );
60 std::string rest = key.substr( numE + 1 );
62 if( i + 1 > profiles.size() ) {
63 profiles.resize( i + 1 );
67 profiles[i].key = value;
68 } else if( rest == "cert" ) {
69 profiles[i].cert = value;
70 } else if( rest == "ku" ) {
71 profiles[i].ku = value;
72 } else if( rest == "eku" ) {
73 profiles[i].eku = value;
75 std::cout << "invalid line: " << line1 << std::endl;
81 for( auto& prof : profiles ) {
82 if( prof.cert != "" && prof.key != "" ) {
83 std::cout << "Loading profile... " << std::endl;
84 prof.ca = loadX509FromFile( prof.cert );
85 prof.caKey = loadPkeyFromFile( prof.key );
89 std::cout << profiles.size() << " profiles loaded." << std::endl;
92 std::cerr << "Missing config property key.directory" << std::endl;