From e6b64ceb4e5e18b5a3580895e234ffda9c0eb4e8 Mon Sep 17 00:00:00 2001 From: yeyuning Date: Wed, 13 Dec 2023 15:50:24 +0800 Subject: [PATCH] get xpm mode status Signed-off-by: yeyuning Change-Id: Ibcd7e3cade882062494edebdd9102ae6e2faef83 --- .../code_sign_utils/include/constants.h | 2 ++ .../code_sign_utils/src/code_sign_utils.cpp | 17 +++++++++++++++-- .../config/trusted_cert_path_test.json | 7 +++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/code_sign_utils/include/constants.h b/interfaces/innerkits/code_sign_utils/include/constants.h index 0ffedfe..acbbf69 100644 --- a/interfaces/innerkits/code_sign_utils/include/constants.h +++ b/interfaces/innerkits/code_sign_utils/include/constants.h @@ -25,6 +25,8 @@ namespace Constants { const std::string FSV_SIG_SUFFIX = ".fsv-sig"; const std::string ENABLE_SIGNATURE_FILE_BASE_PATH = "/data/service/el1/public/bms/bundle_manager_service"; const std::string ENABLE_APP_BASE_PATH = "/data/app/el1/bundle/public"; +const std::string XPM_DEBUG_FS_MODE_PATH = "/proc/sys/kernel/xpm/xpm_mode"; +const std::string SUPPORT_OH_SDK_CODE_SIGN = "1"; } } } diff --git a/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp b/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp index 7625264..7e7bfb2 100644 --- a/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp +++ b/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp @@ -14,7 +14,8 @@ */ #include "code_sign_utils.h" - +#include +#include #include #include #include @@ -321,7 +322,19 @@ int32_t CodeSignUtils::RemoveKeyInProfile(const std::string &bundleName) bool CodeSignUtils::isSupportOHCodeSign() { #ifdef SUPPORT_OH_CODE_SIGN - return true; + std::ifstream file(Constants::XPM_DEBUG_FS_MODE_PATH); + if (!file.is_open()) { + return false; + } + + std::string content; + file >> content; + file.close(); + + if (content == Constants::SUPPORT_OH_SDK_CODE_SIGN) { + return true; + } + return false; #else return false; #endif diff --git a/services/key_enable/config/trusted_cert_path_test.json b/services/key_enable/config/trusted_cert_path_test.json index 9ae3e27..0802282 100644 --- a/services/key_enable/config/trusted_cert_path_test.json +++ b/services/key_enable/config/trusted_cert_path_test.json @@ -71,6 +71,13 @@ "subject":"", "issuer":"", "max-certs-path":3 + }, + { + "mode":"Dev", + "type":"Authed", + "subject":"C=CN, O=Organization, OU=Unit, CN=ide_demo_app", + "issuer":"C=CN, O=OpenHarmony, OU=OpenHarmony Team, CN=OpenHarmony Application CA", + "max-certs-path":3 } ] } \ No newline at end of file -- Gitee