当前位置:   article > 正文

OpenHarmony应用签名 - 厂商私有签名的配置和使用_openharmony udid

openharmony udid

概述

文档环境

开发环境:Windows 11

DevEco Studio 版本:DevEco Studio 3.1.1 Release(3.1.0.501)

SDK 版本:3.2.14.1(Full SDK)

开发板型号:DAYU 200

系统版本:OpenHarmony 3.2 Release(3.2.14.5)

涉及仓库:​​Hap包签名工具[developtools_hapsigner]​

功能简介

OpenHarmony应用签名 - 厂商私有签名文章介绍如何生成厂商私有签名和修改运行系统中的配置文件,使私有签名签出的应用可以正常在系统中安装和使用。

本文我们将介绍:

  • 私有签名信息和密钥如何在系统源码中进行配置,使系统原生支持私有厂商签名签出的应用安装。
  • 部分的系统应用是由编译子系统编译成hap装入系统中,如何配置这些系统应用的签名。
  • 如何使用Debug级别的签名文件给应用签名。
  • 厂商私有签名如何在DevEco Studio的工程中进行配置。

说明:本文档使用的签名文件和密钥等信息已由OpenHarmony应用签名 - 厂商私有签名文档生成。

配置源码私有签名验证信息

1. 配置trusted_apps_sources.json文件,增加私有签名信息。注意“,”符号后面需要加入空格才可正常匹配。文件源码位置:

base/security/appverify/interfaces/innerkits/appverify/config/OpenHarmony/trusted_apps_sources.json

  1. {
  2. "name":"OpenHarmony-Tizi apps",
  3. "app-signing-cert":"C=CN, O=OpenHarmony-Tizi-app-cert, OU=OpenHarmony-Tizi-app-cert Community, CN=OpenHarmony Application Release",
  4. "profile-signing-certificate":"C=CN, O=OpenHarmony-Tizi-profile-cert, OU=OpenHarmony-Tizi-profile-cert Community, CN=OpenHarmony Application Profile Release",
  5. "profile-debug-signing-certificate":"C=CN, O=OpenHarmony-Tizi-profile-cert, OU=OpenHarmony-Tizi-profile-cert Community, CN=OpenHarmony Application Profile Debug",
  6. "issuer-ca":"C=CN, O=OpenHarmony-Tizi-subCA, OU=OpenHarmony-Tizi-subCA Community, CN=OpenHarmony Application CA",
  7. "max-certs-path":3,
  8. "critialcal-cert-extension":["keyusage"]
  9. }

2. 配置trusted_root_ca.json文件,将OpenHarmony-Tizi-rootCA.cer密钥信息处理后加入到文件中。文件源码位置:

base/security/appverify/interfaces/innerkits/appverify/config/OpenHarmony/trusted_root_ca.json\

"C=CN, O=OpenHarmony-Tizi-rootCA, OU=OpenHarmony-Tizi-rootCA Community, CN=OpenHarmony Application Root CA":"-----BEGIN CERTIFICATE-----\nMIICQzCCAemgAwIBAgIEUwKY8TAKBggqhkjOPQQDAjCBhTELMAkGA1UEBhMCQ04x\nIDAeBgNVBAoMF09wZW5IYXJtb255LVRpemktcm9vdENBMSowKAYDVQQLDCFPcGVu\nSGFybW9ueS1UaXppLXJvb3RDQSBDb21tdW5pdHkxKDAmBgNVBAMMH09wZW5IYXJt\nb255IEFwcGxpY2F0aW9uIFJvb3QgQ0EwHhcNMjMwNTIxMTQwNTI2WhcNMjQwNTIw\nMTQwNTI2WjCBhTELMAkGA1UEBhMCQ04xIDAeBgNVBAoMF09wZW5IYXJtb255LVRp\nemktcm9vdENBMSowKAYDVQQLDCFPcGVuSGFybW9ueS1UaXppLXJvb3RDQSBDb21t\ndW5pdHkxKDAmBgNVBAMMH09wZW5IYXJtb255IEFwcGxpY2F0aW9uIFJvb3QgQ0Ew\nWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARoC3C5WijOQkLq/AjmtEWkZ+Ooso1p\nRl34qPpEPH0b6iun5wpAlDe20bcCvsiFda2RNXFsqHIl+cj59bnLh83Ro0UwQzAd\nBgNVHQ4EFgQUAIpcSDCk3q3hZ+qwobekzT9vLHAwEgYDVR0TAQH/BAgwBgEB/wIB\nADAOBgNVHQ8BAf8EBAMCAQYwCgYIKoZIzj0EAwIDSAAwRQIhANKbxPqFT5PwURVf\n1Oxa8cf1udcgO0ntULei/GhaQIobAiBH787oVyJtKxMuPw9K6zzhJjBNjZzW0DrK\n/NOyuKLetw==\n-----END CERTIFICATE-----\n"

3. 重新编译系统镜像,烧录至设备,使用私有签名签出的应用安装测试。

配置源码编译应用的签名文件

以权限管理应用(com.ohos.permissionmanager)为例,其他应用可根据需求配置。

应用源码位置:applications/standard/permission_manager

应用编译信息:

  1. // applications/standard/permission_manager/permissionmanager/BUILD.gn
  2. ohos_hap("permission_manager") {
  3. hap_profile = "src/main/module.json"
  4. deps = [
  5. ":permission_manager_js_assets",
  6. ":permission_manager_resources",
  7. ]
  8. certificate_profile = "../signature/pm.p7b"
  9. hap_name = "permission_manager"
  10. part_name = "prebuilt_hap"
  11. subsystem_name = "applications"
  12. js_build_mode = "debug"
  13. module_install_dir = "app/com.ohos.permissionmanager"
  14. }

1. 使用hap-sign-tool.jar查看原权限管理应用p7b签名文件信息对应的Profile签名证书信息。

p7b文件位置:applications/standard/permission_manager/signature/pm.p7b

java -jar hap-sign-tool.jar verify-profile -inFile pm.p7b -outFil

e pm.json

2. 将bundle-nameaplapp-featureallowed-acls字段分别复制到UnsgnedReleasedProfileTemplate.json文件中。

3. 通过文本查看的方式打开p7b文件,把app-privilege-capabilities字段信息拷贝到UnsgnedReleasedProfileTemplate.json文件中。

说明:验签JSON未输出app-privilege-capabilities字段,已与开发反馈,步骤3为临时方案,后续如有修改会进行文档更新。

4. 替换distribution-certificate为私有签名OpenHarmony-Tizi-app-cert.pem文件中第一部分的密钥。把回车转换为\n字符,替换UnsgnedReleasedProfileTemplate.json文件的distribution-certificate字段。例如:

转换前:

  1. -----BEGIN CERTIFICATE-----
  2. MIICazCCAhGgAwIBAgIFAPERF2IwCgYIKoZIzj0EAwIwgYIxCzAJBgNVBAYTAkNO
  3. MR8wHQYDVQQKDBZPcGVuSGFybW9ueS1UaXppLXN1YkNBMSkwJwYDVQQLDCBPcGVu
  4. SGFybW9ueS1UaXppLXN1YkNBIENvbW11bml0eTEnMCUGA1UEAwweT3Blbkhhcm1v
  5. bnkgQXBwbGljYXRpb24gU3ViIENBMB4XDTIzMDUyMTE0MDU0M1oXDTI0MDUyMDE0
  6. MDU0M1owgYkxCzAJBgNVBAYTAkNOMSIwIAYDVQQKDBlPcGVuSGFybW9ueS1UaXpp
  7. LWFwcC1jZXJ0MSwwKgYDVQQLDCNPcGVuSGFybW9ueS1UaXppLWFwcC1jZXJ0IENv
  8. bW11bml0eTEoMCYGA1UEAwwfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFz
  9. ZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABN0OL1RqzWXQWCXpT0tt54aFR0Ul
  10. 7pqZYBJaCKT049xUYcfwCHLd0q0IzktNo9nqKIjE5BxOk76w7kHhxwowI2qjazBp
  11. MB0GA1UdDgQWBBQAW6LlxgLrPko7kHS/jbcsqnh4WTAJBgNVHRMEAjAAMA4GA1Ud
  12. DwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQME
  13. CDAGAgEBCgEAMAoGCCqGSM49BAMCA0gAMEUCIQDHIWx4AELONvCoKaQnHQAW0bay
  14. gjR168gmlnGfnFGowAIgfMV5/nIvmRAbpapqO3a2pBKeHFfeU5zel/T1Bgty198=
  15. -----END CERTIFICATE-----

转换后:

-----BEGIN CERTIFICATE-----\nMIICazCCAhGgAwIBAgIFAPERF2IwCgYIKoZIzj0EAwIwgYIxCzAJBgNVBAYTAkNO\nMR8wHQYDVQQKDBZPcGVuSGFybW9ueS1UaXppLXN1YkNBMSkwJwYDVQQLDCBPcGVu\nSGFybW9ueS1UaXppLXN1YkNBIENvbW11bml0eTEnMCUGA1UEAwweT3Blbkhhcm1v\nbnkgQXBwbGljYXRpb24gU3ViIENBMB4XDTIzMDUyMTE0MDU0M1oXDTI0MDUyMDE0\nMDU0M1owgYkxCzAJBgNVBAYTAkNOMSIwIAYDVQQKDBlPcGVuSGFybW9ueS1UaXpp\nLWFwcC1jZXJ0MSwwKgYDVQQLDCNPcGVuSGFybW9ueS1UaXppLWFwcC1jZXJ0IENv\nbW11bml0eTEoMCYGA1UEAwwfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFz\nZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABN0OL1RqzWXQWCXpT0tt54aFR0Ul\n7pqZYBJaCKT049xUYcfwCHLd0q0IzktNo9nqKIjE5BxOk76w7kHhxwowI2qjazBp\nMB0GA1UdDgQWBBQAW6LlxgLrPko7kHS/jbcsqnh4WTAJBgNVHRMEAjAAMA4GA1Ud\nDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQME\nCDAGAgEBCgEAMAoGCCqGSM49BAMCA0gAMEUCIQDHIWx4AELONvCoKaQnHQAW0bay\ngjR168gmlnGfnFGowAIgfMV5/nIvmRAbpapqO3a2pBKeHFfeU5zel/T1Bgty198=\n-----END CERTIFICATE-----\n

完整的UnsgnedReleasedProfileTemplate.json文件:

  1. {
  2. "version-name": "2.0.0",
  3. "version-code": 2,
  4. "app-distribution-type": "os_integration",
  5. "uuid": "5027b99e-5f9e-465d-9508-a9e0134ffe18",
  6. "validity": {
  7. "not-before": 1594865258,
  8. "not-after": 1689473258
  9. },
  10. "type": "release",
  11. "bundle-info": {
  12. "developer-id": "OpenHarmony",
  13. "distribution-certificate": "-----BEGIN CERTIFICATE-----\nMIICazCCAhGgAwIBAgIFAPERF2IwCgYIKoZIzj0EAwIwgYIxCzAJBgNVBAYTAkNO\nMR8wHQYDVQQKDBZPcGVuSGFybW9ueS1UaXppLXN1YkNBMSkwJwYDVQQLDCBPcGVu\nSGFybW9ueS1UaXppLXN1YkNBIENvbW11bml0eTEnMCUGA1UEAwweT3Blbkhhcm1v\nbnkgQXBwbGljYXRpb24gU3ViIENBMB4XDTIzMDUyMTE0MDU0M1oXDTI0MDUyMDE0\nMDU0M1owgYkxCzAJBgNVBAYTAkNOMSIwIAYDVQQKDBlPcGVuSGFybW9ueS1UaXpp\nLWFwcC1jZXJ0MSwwKgYDVQQLDCNPcGVuSGFybW9ueS1UaXppLWFwcC1jZXJ0IENv\nbW11bml0eTEoMCYGA1UEAwwfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFz\nZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABN0OL1RqzWXQWCXpT0tt54aFR0Ul\n7pqZYBJaCKT049xUYcfwCHLd0q0IzktNo9nqKIjE5BxOk76w7kHhxwowI2qjazBp\nMB0GA1UdDgQWBBQAW6LlxgLrPko7kHS/jbcsqnh4WTAJBgNVHRMEAjAAMA4GA1Ud\nDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQME\nCDAGAgEBCgEAMAoGCCqGSM49BAMCA0gAMEUCIQDHIWx4AELONvCoKaQnHQAW0bay\ngjR168gmlnGfnFGowAIgfMV5/nIvmRAbpapqO3a2pBKeHFfeU5zel/T1Bgty198=\n-----END CERTIFICATE-----\n",
  14. "bundle-name": "com.ohos.permissionmanager",
  15. "apl": "normal",
  16. "app-feature": "hos_system_app"
  17. },
  18. "acls": {
  19. "allowed-acls": [
  20. "ohos.permission.GET_SENSITIVE_PERMISSIONS",
  21. "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
  22. "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
  23. "ohos.permission.PERMISSION_USED_STATS",
  24. "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
  25. "ohos.permission.GET_BUNDLE_INFO",
  26. "ohos.permission.MANAGE_AUDIO_CONFIG",
  27. "ohos.permission.MANAGE_CAMERA_CONFIG"
  28. ]
  29. },
  30. "permissions": {
  31. "restricted-permissions": []
  32. },
  33. "issuer": "pki_internal",
  34. "app-privilege-capabilities": [
  35. "AllowAppDesktopIconHide",
  36. "AllowAbilityExcludeFromMissions",
  37. "AllowAppUsePrivilegeExtension"
  38. ]
  39. }

5. ProvisionProfile文件签名,生成权限管理应用的p7b文件。

java -jar hap-sign-tool.jar sign-profile -keyAlias "OpenHarmony-Tizi-profileCA" -signAlg "SHA256withECDSA" -mode "localSign" -profileCertFile "OpenHarmony-Tizi-profile-cert-release.pem" -inFile "UnsgnedReleasedProfileTemplate.json" -keystoreFile "OpenHarmony-Tizi.p12" -outFile "pm.p7b" -keyPwd "Pwd-Tizi-5" -keystorePwd "Pwd-Tizi-2"

6. 将pm.p7b文件替换源码中原p7b文件。

7. 修改编译签名信息。

通过build/ohos/app/app_internal.gni文件查看应用签名需要的编译参数。

  1. _private_key_path = default_hap_private_key_path
  2. if (defined(private_key_path)) {
  3. _private_key_path = private_key_path
  4. }
  5. _signature_algorithm = default_signature_algorithm
  6. if (defined(signature_algorithm)) {
  7. _signature_algorithm = signature_algorithm
  8. }
  9. _key_alias = default_key_alias
  10. if (defined(key_alias)) {
  11. _key_alias = key_alias
  12. }
  13. _keystore_path = default_keystore_path
  14. if (defined(keystore_path)) {
  15. _keystore_path = keystore_path
  16. }
  17. _keystore_password = default_keystore_password
  18. if (defined(keystore_password)) {
  19. _keystore_password = keystore_password
  20. }
  21. _certificate_file = default_hap_certificate_file
  22. if (defined(certificate_file)) {
  23. _certificate_file = certificate_file
  24. }

默认编译签名信息位于源码位置build/ohos_var.gni。

  1. default_hap_private_key_path = "OpenHarmony Application Release"
  2. default_signature_algorithm = "SHA256withECDSA"
  3. default_key_alias = "123456"
  4. default_keystore_password = "123456"
  5. default_keystore_path = "//developtools/hapsigner/dist/OpenHarmony.p12"
  6. default_hap_certificate_file =
  7. "//developtools/hapsigner/dist/OpenHarmonyApplication.pem"

编译配置字段

hap-sign-tool.jar字段

签名信息

default_hap_private_key_path

keyAlias

OpenHarmony-Tizi-subCA

default_signature_algorithm

signAlg

SHA256withECDSA

default_key_alias

keyPwd

Pwd-Tizi-4

default_keystore_password

keystorePwd

Pwd-Tizi-2

default_keystore_path

keystoreFile

OpenHarmony-Tizi.p12

default_hap_certificate_file

appCertFile 

OpenHarmony-Tizi-app-cert.pem

说明:编译字段default_hap_private_key_path和default_key_alias的命名与hap-sign-tool.jar字段的命名有出入,但是与build/scripts/hapbuilder.py中sign_hap函数中的取值相对应,需注意,目前已与开发反馈,后续如有修改会进行文档更新。

  1. def sign_hap(hapsigner, private_key_path, sign_algo, certificate_profile,
  2. keystore_path, keystorepasswd, keyalias, certificate_file,
  3. unsigned_hap_path, signed_hap_path):
  4. cmd = ['java', '-jar', hapsigner, 'sign-app']
  5. cmd.extend(['-mode', 'localsign'])
  6. cmd.extend(['-signAlg', sign_algo])
  7. cmd.extend(['-keyAlias', private_key_path])
  8. cmd.extend(['-inFile', unsigned_hap_path])
  9. cmd.extend(['-outFile', signed_hap_path])
  10. cmd.extend(['-profileFile', certificate_profile])
  11. cmd.extend(['-keystoreFile', keystore_path])
  12. cmd.extend(['-keystorePwd', keystorepasswd])
  13. cmd.extend(['-keyPwd', keyalias])
  14. cmd.extend(['-appCertFile', certificate_file])
  15. cmd.extend(['-profileSigned', '1'])
  16. cmd.extend(['-inForm','zip'])
  17. child = subprocess.Popen(cmd,
  18. stdout=subprocess.PIPE,
  19. stderr=subprocess.PIPE)
  20. stdout, stderr = child.communicate()
  21. if child.returncode:
  22. print(stdout.decode(), stderr.decode())
  23. raise Exception("Failed to sign hap")

此处如果修改默认签名配置,则全部由系统编译生成的应用都需要替换p7b文件。本文档仅替换了权限管理应用的p7b文件,所以单独配置权限管理应用的编译配置。

  1. // applications/standard/permission_manager/permissionmanager/BUILD.gn
  2. ohos_hap("permission_manager") {
  3. hap_profile = "src/main/module.json"
  4. deps = [
  5. ":permission_manager_js_assets",
  6. ":permission_manager_resources",
  7. ]
  8. certificate_profile = "../signature/pm.p7b"
  9. hap_name = "permission_manager"
  10. part_name = "prebuilt_hap"
  11. subsystem_name = "applications"
  12. js_build_mode = "debug"
  13. module_install_dir = "app/com.ohos.permissionmanager"
  14. private_key_path = "OpenHarmony-Tizi-subCA" // 增加的签名配置信息
  15. signature_algorithm = "SHA256withECDSA" // 增加的签名配置信息
  16. key_alias = "Pwd-Tizi-4" // 增加的签名配置信息
  17. keystore_path = "//developtools/hapsigner/dist/OpenHarmony-Tizi.p12" // 增加的签名配置信息
  18. keystore_password = "Pwd-Tizi-2" // 增加的签名配置信息
  19. certificate_file = "//developtools/hapsigner/dist/OpenHarmony-Tizi-app-cert.pem" // 增加的签名配置信息
  20. }

8. 将p12文件和pem文件放到步骤7中编译配置的源码目录中。

9. 由于p7b文件的替换,所以预安装配置文件中的app_signature也会被改变,需要重新生成,生成方法可以参考OpenHarmony应用开发技巧 - 如何获取证书指纹

权限管理应用生成app_signature

app_signature:F433242143C463C5931D84E127DA67A6B00B02C5625C17AA2EAA77A393400A33

替换install_list_capability.json文件,权限管理应用指纹信息。

  1. // vendor/hihope/rk3568/preinstall-config/install_list_capability.json
  2. {
  3. "bundleName": "com.ohos.permissionmanager",
  4. "app_signature": ["F433242143C463C5931D84E127DA67A6B00B02C5625C17AA2EAA77A393400A33"],
  5. "allowAppUsePrivilegeExtension": true
  6. },

10. 重新编译系统镜像,烧录至设备,查看权限管理应用是否被正确安装,并验证指纹信息是否与新生成的指纹信息一致。

bm dump -n com.ohos.permissionmanager | grep finger

如何签出Debug等级权限应用

生成Debug等级的p7b文件需要用到UnsgnedDebugProfileTemplate.json和OpenHarmony-Tizi-profile-cert-debug.pem文件。

未修改的UnsgnedDebugProfileTemplate.json:

Release配置文件区别在Debug配置文件增加了debug-info字段,Debug签名需要指定安装设备的udid

1. 获取设备udid。

hdc shell "bm get --udid"

3BCB000C4E2B33075C2759B3A454AF51D7BFF3D2AA489879F70D829E272F03F3

2. 配置UnsgnedDebugProfileTemplate.json文件,将设备udiddevelopment-certificate信息配置进文件。development-certificate的配置方式与Release配置文件相同,可以参考“配置源码编译应用的签名文件”章节的步骤4

配置后的UnsgnedDebugProfileTemplate.json文件

  1. {
  2. "version-name": "2.0.0",
  3. "version-code": 2,
  4. "uuid": "fe686e1b-3770-4824-a938-961b140a7c98",
  5. "validity": {
  6. "not-before": 1610519532,
  7. "not-after": 1705127532
  8. },
  9. "type": "debug",
  10. "bundle-info": {
  11. "developer-id": "OpenHarmony",
  12. "development-certificate": "-----BEGIN CERTIFICATE-----\nMIICazCCAhGgAwIBAgIFAPERF2IwCgYIKoZIzj0EAwIwgYIxCzAJBgNVBAYTAkNO\nMR8wHQYDVQQKDBZPcGVuSGFybW9ueS1UaXppLXN1YkNBMSkwJwYDVQQLDCBPcGVu\nSGFybW9ueS1UaXppLXN1YkNBIENvbW11bml0eTEnMCUGA1UEAwweT3Blbkhhcm1v\nbnkgQXBwbGljYXRpb24gU3ViIENBMB4XDTIzMDUyMTE0MDU0M1oXDTI0MDUyMDE0\nMDU0M1owgYkxCzAJBgNVBAYTAkNOMSIwIAYDVQQKDBlPcGVuSGFybW9ueS1UaXpp\nLWFwcC1jZXJ0MSwwKgYDVQQLDCNPcGVuSGFybW9ueS1UaXppLWFwcC1jZXJ0IENv\nbW11bml0eTEoMCYGA1UEAwwfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFz\nZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABN0OL1RqzWXQWCXpT0tt54aFR0Ul\n7pqZYBJaCKT049xUYcfwCHLd0q0IzktNo9nqKIjE5BxOk76w7kHhxwowI2qjazBp\nMB0GA1UdDgQWBBQAW6LlxgLrPko7kHS/jbcsqnh4WTAJBgNVHRMEAjAAMA4GA1Ud\nDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQME\nCDAGAgEBCgEAMAoGCCqGSM49BAMCA0gAMEUCIQDHIWx4AELONvCoKaQnHQAW0bay\ngjR168gmlnGfnFGowAIgfMV5/nIvmRAbpapqO3a2pBKeHFfeU5zel/T1Bgty198=\n-----END CERTIFICATE-----\n",
  13. "bundle-name": "com.openharmony.signtest",
  14. "apl": "normal",
  15. "app-feature": "hos_normal_app"
  16. },
  17. "acls": {
  18. "allowed-acls": [
  19. ""
  20. ]
  21. },
  22. "permissions": {
  23. "restricted-permissions": [
  24. ""
  25. ]
  26. },
  27. "debug-info": {
  28. "device-ids": [
  29. "3BCB000C4E2B33075C2759B3A454AF51D7BFF3D2AA489879F70D829E272F03F3"
  30. ],
  31. "device-id-type": "udid"
  32. },
  33. "issuer": "pki_internal"
  34. }

说明:如果不配置udid,在应用安装时报错,error: failed to install bundle. error: signature verification failed due to not trusted app source.

3. ProvisionProfile文件签名,注意需使用OpenHarmony-Tizi-profile-cert-debug.pem配合UnsgnedDebugProfileTemplate.json进行签名。

java -jar hap-sign-tool.jar sign-profile -keyAlias "OpenHarmony-Tizi-profileCA" -signAlg "SHA256withECDSA" -mode "localSign" -profileCertFile "OpenHarmony-Tizi-profile-cert-debug.pem" -inFile "UnsgnedDebugProfileTemplate.json" -keystoreFile "OpenHarmony-Tizi.p12" -outFile "com.openharmony.signtest.debug.p7b" -keyPwd "Pwd-Tizi-5" -keystorePwd "Pwd-Tizi-2"

4. hap应用包签名,appCertFile参数与Release版本签名不变,profileFile使用Debug签出的p7b文件。

java -jar hap-sign-tool.jar sign-app -keyAlias "OpenHarmony-Tizi-subCA" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "OpenHarmony-Tizi-app-cert.pem" -profileFile "com.openharmony.signtest.debug.p7b" -inFile "entry-default-unsigned.hap" -keystoreFile "OpenHarmony-Tizi.p12" -outFile "entry-default-signed-debug.hap" -keyPwd "Pwd-Tizi-4" -keystorePwd "Pwd-Tizi-2"

5. 安装应用。

DevEco Studio配置厂商私有签名

以com.openharmony.signtest工程为例。

1. 在工程根路径创建signature文件夹,把应用签名所需文件放入此文件夹下,包括OpenHarmony-Tizi-app-cert.pemOpenHarmony-Tizi.p12com.openharmony.signtest.p7b文件。

2. 更改OpenHarmony-Tizi-app-cert.pem后缀为cer。

3. 单击File > Project Structure > Project > SigningConfigs进入签名配置界面,如果勾选Automatically generate signature则需取消勾选。选取签名文件和配置密钥,点击OK保存配置。

Store file(*.p12):OpenHarmony-Tizi.p12

Store password:Pwd-Tizi-2

Key alias:OpenHarmony-Tizi-subCA

Key password:Pwd-Tizi-4

Sign alg:SHA256withECDSA

Profile file(*.p7b):com.openharmony.signtest.p7b

Certpath file(*.cer):OpenHarmony-Tizi-app-cert.cer

4. 构建安装验证。

参考文档

​​​OpenHarmony Docs - 应用特权配置指南​

​​​OpenHarmony Docs - HarmonyAppProvision配置文件的说明

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/276195?site
推荐阅读
相关标签
  

闽ICP备14008679号