154aa6d63Sopenharmony_ci/* 254aa6d63Sopenharmony_ci * Copyright (c) 2024-2024 Huawei Device Co., Ltd. 354aa6d63Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 454aa6d63Sopenharmony_ci * you may not use this file except in compliance with the License. 554aa6d63Sopenharmony_ci * You may obtain a copy of the License at 654aa6d63Sopenharmony_ci * 754aa6d63Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 854aa6d63Sopenharmony_ci * 954aa6d63Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1054aa6d63Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1154aa6d63Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1254aa6d63Sopenharmony_ci * See the License for the specific language governing permissions and 1354aa6d63Sopenharmony_ci * limitations under the License. 1454aa6d63Sopenharmony_ci */ 1554aa6d63Sopenharmony_ci 1654aa6d63Sopenharmony_ci#include <algorithm> 1754aa6d63Sopenharmony_ci 1854aa6d63Sopenharmony_ci#include "nlohmann/json.hpp" 1954aa6d63Sopenharmony_ci#include "signature_tools_log.h" 2054aa6d63Sopenharmony_ci#include "signature_tools_errno.h" 2154aa6d63Sopenharmony_ci#include "profile_verify.h" 2254aa6d63Sopenharmony_ci 2354aa6d63Sopenharmony_ciusing namespace std; 2454aa6d63Sopenharmony_ciusing namespace nlohmann; 2554aa6d63Sopenharmony_ci 2654aa6d63Sopenharmony_cinamespace { 2754aa6d63Sopenharmony_ciconst string KEY_VERSION_CODE = "version-code"; 2854aa6d63Sopenharmony_ciconst string KEY_VERSION_NAME = "version-name"; 2954aa6d63Sopenharmony_ciconst string KEY_UUID = "uuid"; 3054aa6d63Sopenharmony_ciconst string KEY_TYPE = "type"; 3154aa6d63Sopenharmony_ciconst string KEY_APP_DIST_TYPE = "app-distribution-type"; 3254aa6d63Sopenharmony_ciconst string KEY_BUNDLE_INFO = "bundle-info"; 3354aa6d63Sopenharmony_ciconst string KEY_DEVELOPER_ID = "developer-id"; 3454aa6d63Sopenharmony_ciconst string KEY_DEVELOPMENT_CERTIFICATE = "development-certificate"; 3554aa6d63Sopenharmony_ciconst string KEY_DISTRIBUTION_CERTIFICATE = "distribution-certificate"; 3654aa6d63Sopenharmony_ciconst string KEY_BUNDLE_NAME = "bundle-name"; 3754aa6d63Sopenharmony_ciconst string KEY_APL = "apl"; 3854aa6d63Sopenharmony_ciconst string KEY_APP_FEATURE = "app-feature"; 3954aa6d63Sopenharmony_ciconst string KEY_ACLS = "acls"; 4054aa6d63Sopenharmony_ciconst string KEY_ALLOWED_ACLS = "allowed-acls"; 4154aa6d63Sopenharmony_ciconst string KEY_PERMISSIONS = "permissions"; 4254aa6d63Sopenharmony_ciconst string KEY_DATA_GROUP_IDS = "data-group-ids"; 4354aa6d63Sopenharmony_ciconst string KEY_RESTRICTED_PERMISSIONS = "restricted-permissions"; 4454aa6d63Sopenharmony_ciconst string KEY_RESTRICTED_CAPABILITIES = "restricted-capabilities"; 4554aa6d63Sopenharmony_ciconst string KEY_DEBUG_INFO = "debug-info"; 4654aa6d63Sopenharmony_ciconst string KEY_DEVICE_ID_TYPE = "device-id-type"; 4754aa6d63Sopenharmony_ciconst string KEY_DEVICE_IDS = "device-ids"; 4854aa6d63Sopenharmony_ciconst string KEY_ISSUER = "issuer"; 4954aa6d63Sopenharmony_ciconst string KEY_APP_PRIVILEGE_CAPABILITIES = "app-privilege-capabilities"; 5054aa6d63Sopenharmony_ciconst string KEY_APP_SERVICE_CAPABILITIES = "app-service-capabilities"; 5154aa6d63Sopenharmony_ciconst string VALUE_TYPE_RELEASE = "release"; 5254aa6d63Sopenharmony_ciconst string VALUE_TYPE_DEBUG = "debug"; 5354aa6d63Sopenharmony_ciconst string VALUE_DIST_TYPE_APP_GALLERY = "app_gallery"; 5454aa6d63Sopenharmony_ciconst string VALUE_DIST_TYPE_ENTERPRISE = "enterprise"; 5554aa6d63Sopenharmony_ciconst string VALUE_DIST_TYPE_ENTERPRISE_NORMAL = "enterprise_normal"; 5654aa6d63Sopenharmony_ciconst string VALUE_DIST_TYPE_ENTERPRISE_MDM = "enterprise_mdm"; 5754aa6d63Sopenharmony_ciconst string VALUE_DIST_TYPE_OS_INTEGRATION = "os_integration"; 5854aa6d63Sopenharmony_ciconst string VALUE_DIST_TYPE_CROWDTESTING = "crowdtesting"; 5954aa6d63Sopenharmony_ciconst string VALUE_DEVICE_ID_TYPE_UDID = "udid"; 6054aa6d63Sopenharmony_ciconst string VALUE_VALIDITY = "validity"; 6154aa6d63Sopenharmony_ciconst string VALUE_NOT_BEFORE = "not-before"; 6254aa6d63Sopenharmony_ciconst string VALUE_NOT_AFTER = "not-after"; 6354aa6d63Sopenharmony_ci// reserved field 6454aa6d63Sopenharmony_ciconst string KEY_BASEAPP_INFO = "baseapp-info"; 6554aa6d63Sopenharmony_ciconst string KEY_PACKAGE_NAME = "package-name"; 6654aa6d63Sopenharmony_ciconst string KEY_PACKAGE_CERT = "package-cert"; 6754aa6d63Sopenharmony_ciconst string KEY_APP_IDENTIFIER = "app-identifier"; 6854aa6d63Sopenharmony_ciconst string GENERIC_BUNDLE_NAME = ".*"; 6954aa6d63Sopenharmony_ci 7054aa6d63Sopenharmony_ciinline void GetStringIfExist(const json& obj, const string& key, string& out) 7154aa6d63Sopenharmony_ci{ 7254aa6d63Sopenharmony_ci if (obj.find(key.c_str()) != obj.end() && obj[key.c_str()].is_string()) { 7354aa6d63Sopenharmony_ci obj[key.c_str()].get_to(out); 7454aa6d63Sopenharmony_ci } 7554aa6d63Sopenharmony_ci} 7654aa6d63Sopenharmony_ciinline void GetInt32IfExist(const json& obj, const string& key, int32_t& out) 7754aa6d63Sopenharmony_ci{ 7854aa6d63Sopenharmony_ci if (obj.find(key.c_str()) != obj.end() && obj[key.c_str()].is_number_integer()) { 7954aa6d63Sopenharmony_ci obj[key.c_str()].get_to(out); 8054aa6d63Sopenharmony_ci } 8154aa6d63Sopenharmony_ci} 8254aa6d63Sopenharmony_ciinline void GetInt64IfExist(const json& obj, const string& key, int64_t& out) 8354aa6d63Sopenharmony_ci{ 8454aa6d63Sopenharmony_ci if (obj.find(key.c_str()) != obj.end() && obj[key.c_str()].is_number_integer()) { 8554aa6d63Sopenharmony_ci obj[key.c_str()].get_to(out); 8654aa6d63Sopenharmony_ci } 8754aa6d63Sopenharmony_ci} 8854aa6d63Sopenharmony_ciinline void GetStringArrayIfExist(const json& obj, const string& key, vector<string>& out) 8954aa6d63Sopenharmony_ci{ 9054aa6d63Sopenharmony_ci if (obj.find(key.c_str()) != obj.end() && obj[key.c_str()].is_array()) { 9154aa6d63Sopenharmony_ci for (auto& item : obj[key.c_str()]) { 9254aa6d63Sopenharmony_ci if (item.is_string()) { 9354aa6d63Sopenharmony_ci out.push_back(item.get<string>()); 9454aa6d63Sopenharmony_ci } 9554aa6d63Sopenharmony_ci } 9654aa6d63Sopenharmony_ci } 9754aa6d63Sopenharmony_ci} 9854aa6d63Sopenharmony_ciinline bool IsObjectExist(const json& obj, const string& key) 9954aa6d63Sopenharmony_ci{ 10054aa6d63Sopenharmony_ci return obj.find(key.c_str()) != obj.end() && obj[key.c_str()].is_object(); 10154aa6d63Sopenharmony_ci} 10254aa6d63Sopenharmony_ci} // namespace 10354aa6d63Sopenharmony_cinamespace OHOS { 10454aa6d63Sopenharmony_cinamespace SignatureTools { 10554aa6d63Sopenharmony_ciconst std::map<std::string, int32_t> distTypeMap = { 10654aa6d63Sopenharmony_ci {VALUE_DIST_TYPE_APP_GALLERY, AppDistType::APP_GALLERY}, 10754aa6d63Sopenharmony_ci {VALUE_DIST_TYPE_ENTERPRISE, AppDistType::ENTERPRISE}, 10854aa6d63Sopenharmony_ci {VALUE_DIST_TYPE_ENTERPRISE_NORMAL, AppDistType::ENTERPRISE_NORMAL}, 10954aa6d63Sopenharmony_ci {VALUE_DIST_TYPE_ENTERPRISE_MDM, AppDistType::ENTERPRISE_MDM}, 11054aa6d63Sopenharmony_ci {VALUE_DIST_TYPE_OS_INTEGRATION, AppDistType::OS_INTEGRATION}, 11154aa6d63Sopenharmony_ci {VALUE_DIST_TYPE_CROWDTESTING, AppDistType::CROWDTESTING} 11254aa6d63Sopenharmony_ci}; 11354aa6d63Sopenharmony_ci 11454aa6d63Sopenharmony_civoid ParseType(const json& obj, ProfileInfo& out) 11554aa6d63Sopenharmony_ci{ 11654aa6d63Sopenharmony_ci string type; 11754aa6d63Sopenharmony_ci GetStringIfExist(obj, KEY_TYPE, type); 11854aa6d63Sopenharmony_ci /* If not release, then it's debug */ 11954aa6d63Sopenharmony_ci if (type == VALUE_TYPE_RELEASE) 12054aa6d63Sopenharmony_ci out.type = RELEASE; 12154aa6d63Sopenharmony_ci else if (type == VALUE_TYPE_DEBUG) 12254aa6d63Sopenharmony_ci out.type = DEBUG; 12354aa6d63Sopenharmony_ci else out.type = NONE_PROVISION_TYPE; 12454aa6d63Sopenharmony_ci} 12554aa6d63Sopenharmony_civoid ParseAppDistType(const json& obj, ProfileInfo& out) 12654aa6d63Sopenharmony_ci{ 12754aa6d63Sopenharmony_ci string distType; 12854aa6d63Sopenharmony_ci GetStringIfExist(obj, KEY_APP_DIST_TYPE, distType); 12954aa6d63Sopenharmony_ci auto ite = distTypeMap.find(distType); 13054aa6d63Sopenharmony_ci if (ite != distTypeMap.end()) { 13154aa6d63Sopenharmony_ci out.distributionType = static_cast<AppDistType>(distTypeMap.at(distType)); 13254aa6d63Sopenharmony_ci return; 13354aa6d63Sopenharmony_ci } 13454aa6d63Sopenharmony_ci out.distributionType = AppDistType::NONE_TYPE; 13554aa6d63Sopenharmony_ci} 13654aa6d63Sopenharmony_civoid ParseBundleInfo(const json& obj, ProfileInfo& out) 13754aa6d63Sopenharmony_ci{ 13854aa6d63Sopenharmony_ci if (IsObjectExist(obj, KEY_BUNDLE_INFO)) { 13954aa6d63Sopenharmony_ci const auto& bundleInfo = obj[KEY_BUNDLE_INFO]; 14054aa6d63Sopenharmony_ci GetStringIfExist(bundleInfo, KEY_DEVELOPER_ID, out.bundleInfo.developerId); 14154aa6d63Sopenharmony_ci GetStringIfExist(bundleInfo, KEY_DEVELOPMENT_CERTIFICATE, 14254aa6d63Sopenharmony_ci out.bundleInfo.developmentCertificate); 14354aa6d63Sopenharmony_ci GetStringIfExist(bundleInfo, KEY_DISTRIBUTION_CERTIFICATE, 14454aa6d63Sopenharmony_ci out.bundleInfo.distributionCertificate); 14554aa6d63Sopenharmony_ci GetStringIfExist(bundleInfo, KEY_BUNDLE_NAME, out.bundleInfo.bundleName); 14654aa6d63Sopenharmony_ci GetStringIfExist(bundleInfo, KEY_APL, out.bundleInfo.apl); 14754aa6d63Sopenharmony_ci GetStringIfExist(bundleInfo, KEY_APP_FEATURE, out.bundleInfo.appFeature); 14854aa6d63Sopenharmony_ci GetStringIfExist(bundleInfo, KEY_APP_IDENTIFIER, out.bundleInfo.appIdentifier); 14954aa6d63Sopenharmony_ci GetStringArrayIfExist(bundleInfo, KEY_DATA_GROUP_IDS, out.bundleInfo.dataGroupIds); 15054aa6d63Sopenharmony_ci } 15154aa6d63Sopenharmony_ci} 15254aa6d63Sopenharmony_civoid ParseAcls(const json& obj, ProfileInfo& out) 15354aa6d63Sopenharmony_ci{ 15454aa6d63Sopenharmony_ci if (IsObjectExist(obj, KEY_ACLS)) { 15554aa6d63Sopenharmony_ci const auto& acls = obj[KEY_ACLS]; 15654aa6d63Sopenharmony_ci GetStringArrayIfExist(acls, KEY_ALLOWED_ACLS, out.acls.allowedAcls); 15754aa6d63Sopenharmony_ci } 15854aa6d63Sopenharmony_ci} 15954aa6d63Sopenharmony_civoid ParsePermissions(const json& obj, ProfileInfo& out) 16054aa6d63Sopenharmony_ci{ 16154aa6d63Sopenharmony_ci if (IsObjectExist(obj, KEY_PERMISSIONS)) { 16254aa6d63Sopenharmony_ci const auto& permissions = obj[KEY_PERMISSIONS]; 16354aa6d63Sopenharmony_ci GetStringArrayIfExist(permissions, KEY_RESTRICTED_PERMISSIONS, 16454aa6d63Sopenharmony_ci out.permissions.restrictedPermissions); 16554aa6d63Sopenharmony_ci GetStringArrayIfExist(permissions, KEY_RESTRICTED_CAPABILITIES, 16654aa6d63Sopenharmony_ci out.permissions.restrictedCapabilities); 16754aa6d63Sopenharmony_ci } 16854aa6d63Sopenharmony_ci} 16954aa6d63Sopenharmony_civoid ParseDebugInfo(const json& obj, ProfileInfo& out) 17054aa6d63Sopenharmony_ci{ 17154aa6d63Sopenharmony_ci if (IsObjectExist(obj, KEY_DEBUG_INFO)) { 17254aa6d63Sopenharmony_ci GetStringIfExist(obj[KEY_DEBUG_INFO], KEY_DEVICE_ID_TYPE, out.debugInfo.deviceIdType); 17354aa6d63Sopenharmony_ci GetStringArrayIfExist(obj[KEY_DEBUG_INFO], KEY_DEVICE_IDS, out.debugInfo.deviceIds); 17454aa6d63Sopenharmony_ci } 17554aa6d63Sopenharmony_ci} 17654aa6d63Sopenharmony_civoid ParseValidity(const json& obj, Validity& out) 17754aa6d63Sopenharmony_ci{ 17854aa6d63Sopenharmony_ci if (IsObjectExist(obj, VALUE_VALIDITY)) { 17954aa6d63Sopenharmony_ci GetInt64IfExist(obj[VALUE_VALIDITY], VALUE_NOT_BEFORE, out.notBefore); 18054aa6d63Sopenharmony_ci GetInt64IfExist(obj[VALUE_VALIDITY], VALUE_NOT_AFTER, out.notAfter); 18154aa6d63Sopenharmony_ci } 18254aa6d63Sopenharmony_ci} 18354aa6d63Sopenharmony_civoid ParseMetadata(const json& obj, ProfileInfo& out) 18454aa6d63Sopenharmony_ci{ 18554aa6d63Sopenharmony_ci if (IsObjectExist(obj, KEY_BASEAPP_INFO)) { 18654aa6d63Sopenharmony_ci const auto& baseAppInfo = obj[KEY_BASEAPP_INFO]; 18754aa6d63Sopenharmony_ci Metadata metadata; 18854aa6d63Sopenharmony_ci metadata.name = KEY_PACKAGE_NAME; 18954aa6d63Sopenharmony_ci GetStringIfExist(baseAppInfo, KEY_PACKAGE_NAME, metadata.value); 19054aa6d63Sopenharmony_ci out.metadatas.emplace_back(metadata); 19154aa6d63Sopenharmony_ci metadata.name = KEY_PACKAGE_CERT; 19254aa6d63Sopenharmony_ci GetStringIfExist(baseAppInfo, KEY_PACKAGE_CERT, metadata.value); 19354aa6d63Sopenharmony_ci out.metadatas.emplace_back(metadata); 19454aa6d63Sopenharmony_ci } 19554aa6d63Sopenharmony_ci} 19654aa6d63Sopenharmony_civoid from_json(const json& obj, ProfileInfo& out) 19754aa6d63Sopenharmony_ci{ 19854aa6d63Sopenharmony_ci if (!obj.is_object()) { 19954aa6d63Sopenharmony_ci return; 20054aa6d63Sopenharmony_ci } 20154aa6d63Sopenharmony_ci GetInt32IfExist(obj, KEY_VERSION_CODE, out.versionCode); 20254aa6d63Sopenharmony_ci GetStringIfExist(obj, KEY_VERSION_NAME, out.versionName); 20354aa6d63Sopenharmony_ci GetStringIfExist(obj, KEY_UUID, out.uuid); 20454aa6d63Sopenharmony_ci ParseType(obj, out); 20554aa6d63Sopenharmony_ci ParseAppDistType(obj, out); 20654aa6d63Sopenharmony_ci ParseBundleInfo(obj, out); 20754aa6d63Sopenharmony_ci ParseAcls(obj, out); 20854aa6d63Sopenharmony_ci ParsePermissions(obj, out); 20954aa6d63Sopenharmony_ci ParseDebugInfo(obj, out); 21054aa6d63Sopenharmony_ci GetStringIfExist(obj, KEY_ISSUER, out.issuer); 21154aa6d63Sopenharmony_ci GetStringArrayIfExist(obj, KEY_APP_PRIVILEGE_CAPABILITIES, out.appPrivilegeCapabilities); 21254aa6d63Sopenharmony_ci ParseValidity(obj, out.validity); 21354aa6d63Sopenharmony_ci ParseMetadata(obj, out); 21454aa6d63Sopenharmony_ci GetStringIfExist(obj, KEY_APP_SERVICE_CAPABILITIES, out.appServiceCapabilities); 21554aa6d63Sopenharmony_ci} 21654aa6d63Sopenharmony_ci 21754aa6d63Sopenharmony_ciAppProvisionVerifyResult ReturnIfStringIsEmpty(const std::string& str, const std::string& errMsg) 21854aa6d63Sopenharmony_ci{ 21954aa6d63Sopenharmony_ci if (str.empty()) { 22054aa6d63Sopenharmony_ci PrintErrorNumberMsg("PROVISION_INVALID_ERROR", PROVISION_INVALID_ERROR, errMsg); 22154aa6d63Sopenharmony_ci return PROVISION_INVALID; 22254aa6d63Sopenharmony_ci } 22354aa6d63Sopenharmony_ci return PROVISION_OK; 22454aa6d63Sopenharmony_ci} 22554aa6d63Sopenharmony_ci 22654aa6d63Sopenharmony_ciAppProvisionVerifyResult ReturnIfIntIsNonPositive(int num, const std::string& errMsg) 22754aa6d63Sopenharmony_ci{ 22854aa6d63Sopenharmony_ci if (num <= 0) { 22954aa6d63Sopenharmony_ci PrintErrorNumberMsg("PROVISION_INVALID_ERROR", PROVISION_INVALID_ERROR, errMsg); 23054aa6d63Sopenharmony_ci return PROVISION_INVALID; 23154aa6d63Sopenharmony_ci } 23254aa6d63Sopenharmony_ci return PROVISION_OK; 23354aa6d63Sopenharmony_ci} 23454aa6d63Sopenharmony_ci 23554aa6d63Sopenharmony_cistatic AppProvisionVerifyResult CheckProfileValidType(ProfileInfo& info) 23654aa6d63Sopenharmony_ci{ 23754aa6d63Sopenharmony_ci if (info.type == ProvisionType::DEBUG) { 23854aa6d63Sopenharmony_ci if (ReturnIfStringIsEmpty(info.bundleInfo.developmentCertificate, 23954aa6d63Sopenharmony_ci "Tag development-certificate is empty.") != PROVISION_OK) { 24054aa6d63Sopenharmony_ci return PROVISION_INVALID; 24154aa6d63Sopenharmony_ci } 24254aa6d63Sopenharmony_ci } else if (info.type == ProvisionType::RELEASE) { 24354aa6d63Sopenharmony_ci if (ReturnIfIntIsNonPositive(info.distributionType, 24454aa6d63Sopenharmony_ci "Tag app-distribution-type is empty.") != PROVISION_OK) { 24554aa6d63Sopenharmony_ci return PROVISION_INVALID; 24654aa6d63Sopenharmony_ci } 24754aa6d63Sopenharmony_ci if (ReturnIfStringIsEmpty(info.bundleInfo.distributionCertificate, 24854aa6d63Sopenharmony_ci "Tag distribution-certificate is empty.") != PROVISION_OK) { 24954aa6d63Sopenharmony_ci return PROVISION_INVALID; 25054aa6d63Sopenharmony_ci } 25154aa6d63Sopenharmony_ci } else { 25254aa6d63Sopenharmony_ci PrintErrorNumberMsg("PROVISION_INVALID_ERROR", PROVISION_INVALID_ERROR, 25354aa6d63Sopenharmony_ci "The type field in the profile file is incorrect"); 25454aa6d63Sopenharmony_ci return PROVISION_INVALID; 25554aa6d63Sopenharmony_ci } 25654aa6d63Sopenharmony_ci return PROVISION_OK; 25754aa6d63Sopenharmony_ci} 25854aa6d63Sopenharmony_ci 25954aa6d63Sopenharmony_ciAppProvisionVerifyResult ParseProvision(const string& appProvision, ProfileInfo& info) 26054aa6d63Sopenharmony_ci{ 26154aa6d63Sopenharmony_ci if (ParseProfile(appProvision, info) != PROVISION_OK) { 26254aa6d63Sopenharmony_ci return PROVISION_INVALID; 26354aa6d63Sopenharmony_ci } 26454aa6d63Sopenharmony_ci 26554aa6d63Sopenharmony_ci if (CheckProfileValidType(info) != PROVISION_OK) { 26654aa6d63Sopenharmony_ci return PROVISION_INVALID; 26754aa6d63Sopenharmony_ci } 26854aa6d63Sopenharmony_ci return PROVISION_OK; 26954aa6d63Sopenharmony_ci} 27054aa6d63Sopenharmony_ci 27154aa6d63Sopenharmony_ciAppProvisionVerifyResult ParseAndVerify(const string& appProvision, ProfileInfo& info) 27254aa6d63Sopenharmony_ci{ 27354aa6d63Sopenharmony_ci SIGNATURE_TOOLS_LOGD("Enter HarmonyAppProvision Verify"); 27454aa6d63Sopenharmony_ci AppProvisionVerifyResult ret = ParseProvision(appProvision, info); 27554aa6d63Sopenharmony_ci if (ret != PROVISION_OK) { 27654aa6d63Sopenharmony_ci return ret; 27754aa6d63Sopenharmony_ci } 27854aa6d63Sopenharmony_ci SIGNATURE_TOOLS_LOGD("Leave HarmonyAppProvision Verify"); 27954aa6d63Sopenharmony_ci return PROVISION_OK; 28054aa6d63Sopenharmony_ci} 28154aa6d63Sopenharmony_ciAppProvisionVerifyResult ParseProfile(const std::string& appProvision, ProfileInfo& info) 28254aa6d63Sopenharmony_ci{ 28354aa6d63Sopenharmony_ci json obj = json::parse(appProvision, nullptr, false); 28454aa6d63Sopenharmony_ci if (obj.is_discarded() || (!obj.is_structured())) { 28554aa6d63Sopenharmony_ci std::string errStr = "invalid json object, parse provision failed, json: " + appProvision; 28654aa6d63Sopenharmony_ci PrintErrorNumberMsg("PROVISION_INVALID_ERROR", PROVISION_INVALID_ERROR, errStr.c_str()); 28754aa6d63Sopenharmony_ci return PROVISION_INVALID; 28854aa6d63Sopenharmony_ci } 28954aa6d63Sopenharmony_ci obj.get_to(info); 29054aa6d63Sopenharmony_ci return PROVISION_OK; 29154aa6d63Sopenharmony_ci} 29254aa6d63Sopenharmony_ci} // namespace SignatureTools 29354aa6d63Sopenharmony_ci} // namespace OHOS