mirror of
https://gitee.com/openharmony/security_appverify
synced 2024-11-27 08:40:33 +00:00
commit
27e60a2729
@ -26,6 +26,10 @@ namespace Verify {
|
||||
bool JsonParserUtils::ReadTrustedRootCAFromJson(cJSON** jsonObj,
|
||||
const std::string& jsonPath, std::string& error)
|
||||
{
|
||||
if (jsonObj == NULL) {
|
||||
error += "jsonObj is NULL";
|
||||
return false;
|
||||
}
|
||||
std::ifstream jsonFileStream;
|
||||
jsonFileStream.open(jsonPath.c_str(), std::ios::in);
|
||||
if (!jsonFileStream.is_open()) {
|
||||
|
@ -112,6 +112,7 @@ bool TrustedRootCa::GetTrustedRootCAFromJson(StringCertMap& rootCertMap, const s
|
||||
if (cert == nullptr) {
|
||||
HAPVERIFY_LOG_ERROR("GetX509CertFromPemString failed, key: %{public}s value: %{public}s",
|
||||
jsonPair.first.c_str(), jsonPair.second.c_str());
|
||||
cJSON_Delete(trustedRootCAJson);
|
||||
return false;
|
||||
}
|
||||
rootCertMap[jsonPair.first] = cert;
|
||||
@ -119,6 +120,7 @@ bool TrustedRootCa::GetTrustedRootCAFromJson(StringCertMap& rootCertMap, const s
|
||||
|
||||
if (rootCertMap.empty()) {
|
||||
HAPVERIFY_LOG_ERROR("no root cert");
|
||||
cJSON_Delete(trustedRootCAJson);
|
||||
return false;
|
||||
}
|
||||
cJSON_Delete(trustedRootCAJson);
|
||||
|
@ -107,24 +107,29 @@ bool TrustedSourceManager::GetAppTrustedSources(SourceInfoVec& trustedAppSources
|
||||
}
|
||||
if (!JsonParserUtils::GetJsonString(trustedSourceJson, KEY_OF_APP_TRUSTED_SOURCE_VERSION, souucesVersion)) {
|
||||
HAPVERIFY_LOG_ERROR("get version failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
if (!JsonParserUtils::GetJsonString(trustedSourceJson,
|
||||
KEY_OF_APP_TRUSTED_SOURCE_RELEASETIME, souucesReleaseTime)) {
|
||||
HAPVERIFY_LOG_ERROR("get releaseTime failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
JsonObjVec trustedAppSourceJson;
|
||||
if (!JsonParserUtils::ParseJsonToObjVec(trustedSourceJson, KEY_OF_APP_TRUSTED_SOURCE, trustedAppSourceJson)) {
|
||||
HAPVERIFY_LOG_ERROR("get JsonObjVec failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
if (!ParseTrustedAppSourceJson(trustedAppSources, trustedAppSourceJson)) {
|
||||
HAPVERIFY_LOG_ERROR("parse JsonObjVec failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
if (trustedAppSources.empty()) {
|
||||
HAPVERIFY_LOG_ERROR("no app trusted source");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
|
@ -80,24 +80,29 @@ bool TrustedTicketManager::GetTicketTrustedSources(TicketSourceInfoVec& trustedT
|
||||
}
|
||||
if (!JsonParserUtils::GetJsonString(trustedSourceJson, KEY_OF_TICKET_TRUSTED_SOURCE_VERSION, sourcesVersion)) {
|
||||
HAPVERIFY_LOG_ERROR("get version failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
if (!JsonParserUtils::GetJsonString(trustedSourceJson,
|
||||
KEY_OF_TICKET_TRUSTED_SOURCE_RELEASETIME, sourcesReleaseTime)) {
|
||||
HAPVERIFY_LOG_ERROR("get releaseTime failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
JsonObjVec trustedTicketJson;
|
||||
if (!JsonParserUtils::ParseJsonToObjVec(trustedSourceJson, KEY_OF_TICKET_TRUSTED_SOURCE, trustedTicketJson)) {
|
||||
HAPVERIFY_LOG_ERROR("get JsonObjVec failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
if (!ParseTrustedTicketSourceJson(trustedTicketSources, trustedTicketJson)) {
|
||||
HAPVERIFY_LOG_ERROR("parse JsonObjVec failed");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
if (trustedTicketSources.empty()) {
|
||||
HAPVERIFY_LOG_ERROR("no ticket trusted source");
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
return false;
|
||||
}
|
||||
cJSON_Delete(trustedSourceJson);
|
||||
|
@ -253,7 +253,7 @@ void from_json(const cJSON* obj, ProvisionInfo& out)
|
||||
if (dumpString != NULL) {
|
||||
out.appServiceCapabilities = dumpString;
|
||||
}
|
||||
free(dumpString);
|
||||
cJSON_free(dumpString);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user