return crypto_cert_subject_common_name(xcert, & length);
}
-const char* certificate_path()
+char* certificate_path()
{
/*
Assume the .pem file is in the same directory as this source file.
else
{
/* No dirsep => relative path in same directory */
- return filename;
+ return _strdup(filename);
}
}
const certificate_test_t certificate_tests[] =
-{
+ {
{
ENABLED,
"Certificate e-mail",
crypto_cert_get_email,
"testjean.testmartin@test.example.com"
+
},
{
crypto_cert_issuer,
"CN = ADMINISTRATION CENTRALE DES TESTS, C = FR, O = MINISTERE DES TESTS, OU = 0002 110014016"
},
-
};
+
int TestCertificateFile(const char* certificate_path, const certificate_test_t* certificate_tests,
int count)
{
}
certificate = PEM_read_X509(certificate_file, 0, 0, 0);
+ fclose(certificate_file);
if (!certificate)
{
certificate_tests[i].expected_result);
success = -1;
}
+ free(result);
}
else
{
}
fail:
- fclose(certificate_file);
+ X509_free(certificate);
return success;
}
int Test_x509_cert_info(int argc, char* argv[])
{
- return TestCertificateFile(certificate_path(), certificate_tests, ARRAYSIZE(certificate_tests));
+ char* cert_path = certificate_path();
+ int ret = TestCertificateFile(cert_path, certificate_tests, ARRAYSIZE(certificate_tests));
+ free(cert_path);
+ return ret;
}