/**
* Load certificates from the confiuguration file
*/
-static bool load_certs()
+static bool load_certs(settings_t *settings, char *dir)
{
enumerator_t *enumerator;
- char *key, *value;
+ char *key, *value, wd[PATH_MAX];
certificate_t *cert;
- if (chdir(conftest->suite_dir) != 0)
+ if (getcwd(wd, sizeof(wd)) == NULL)
{
- fprintf(stderr, "opening suite directory '%s' failed",
- conftest->suite_dir);
+ fprintf(stderr, "getting cwd failed: %s\n", strerror(errno));
+ return FALSE;
+ }
+ if (chdir(dir) != 0)
+ {
+ fprintf(stderr, "opening directory '%s' failed: %s\n",
+ dir, strerror(errno));
return FALSE;
}
- enumerator = conftest->suite->create_key_value_enumerator(
- conftest->suite, "certs.trusted");
+ enumerator = settings->create_key_value_enumerator(settings, "certs.trusted");
while (enumerator->enumerate(enumerator, &key, &value))
{
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
}
enumerator->destroy(enumerator);
- enumerator = conftest->suite->create_key_value_enumerator(
- conftest->suite, "certs.untrusted");
+ enumerator = settings->create_key_value_enumerator(settings, "certs.untrusted");
while (enumerator->enumerate(enumerator, &key, &value))
{
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
}
enumerator->destroy(enumerator);
+ if (chdir(wd) != 0)
+ {
+ fprintf(stderr, "opening directory '%s' failed: %s\n",
+ wd, strerror(errno));
+ return FALSE;
+ }
return TRUE;
}
{
return 1;
}
- if (!load_certs(suite_file))
+ if (!load_certs(conftest->suite, suite_file) ||
+ !load_certs(conftest->test, test_file))
{
return 1;
}