Load certificates from both, suite and test config
This commit is contained in:
+20
-10
@@ -89,21 +89,25 @@ static bool load_configs(char *suite_file, char *test_file)
|
|||||||
/**
|
/**
|
||||||
* Load certificates from the confiuguration file
|
* Load certificates from the confiuguration file
|
||||||
*/
|
*/
|
||||||
static bool load_certs()
|
static bool load_certs(settings_t *settings, char *dir)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
char *key, *value;
|
char *key, *value, wd[PATH_MAX];
|
||||||
certificate_t *cert;
|
certificate_t *cert;
|
||||||
|
|
||||||
if (chdir(conftest->suite_dir) != 0)
|
if (getcwd(wd, sizeof(wd)) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "opening suite directory '%s' failed",
|
fprintf(stderr, "getting cwd failed: %s\n", strerror(errno));
|
||||||
conftest->suite_dir);
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (chdir(dir) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "opening directory '%s' failed: %s\n",
|
||||||
|
dir, strerror(errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
enumerator = conftest->suite->create_key_value_enumerator(
|
enumerator = settings->create_key_value_enumerator(settings, "certs.trusted");
|
||||||
conftest->suite, "certs.trusted");
|
|
||||||
while (enumerator->enumerate(enumerator, &key, &value))
|
while (enumerator->enumerate(enumerator, &key, &value))
|
||||||
{
|
{
|
||||||
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
|
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
|
||||||
@@ -119,8 +123,7 @@ static bool load_certs()
|
|||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
enumerator = conftest->suite->create_key_value_enumerator(
|
enumerator = settings->create_key_value_enumerator(settings, "certs.untrusted");
|
||||||
conftest->suite, "certs.untrusted");
|
|
||||||
while (enumerator->enumerate(enumerator, &key, &value))
|
while (enumerator->enumerate(enumerator, &key, &value))
|
||||||
{
|
{
|
||||||
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
|
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
|
||||||
@@ -136,6 +139,12 @@ static bool load_certs()
|
|||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
|
if (chdir(wd) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "opening directory '%s' failed: %s\n",
|
||||||
|
wd, strerror(errno));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +301,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!load_certs(suite_file))
|
if (!load_certs(conftest->suite, suite_file) ||
|
||||||
|
!load_certs(conftest->test, test_file))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user