openharmony 鸿蒙 binary-sign-tool

2026-08-25 浏览 (1)

Binary Sign Tool

Binary Sign Tool is used to sign code of binary files. It supports code signing of standard ELF files or printing of signed ELF permission and certificate information using commands.

Obtaining the Command Line Tool

  • Tool for Linux platform: Download the latest Command Line Tools. You can obtain the binary-sign-tool file from openHarmony/toolchains/lib of the SDK library.

  • Tool for OpenHarmony PC/2-in-1 device: Download and install DevBox from AppGallery. You can run the binary-sign-tool command in the terminal window without additional configuration.

Commands

CommandDescription
helpDisplays the commands supported by the tool.
signSigns a binary file.
display-signPrints the certificate information of the file signature.

help

# Display the help information.
binary-sign-tool -help

sign

Parameters

ParameterDescription
-keyAliasKey alias, which is mandatory and case-insensitive.
-keyPwdKey password, which is optional.
-appCertFileSigning certificate file (certificate chain, with entity certificate first, then intermediate CA, and root CA last), which is mandatory.
-profileFileSigned provision profile file name, in p7b format, which is optional.
-profileSignedWhether the profile is signed. The value 1 means signed, and value 0 means unsigned. The default value is 1. This parameter is optional.
-signAlgSigning algorithm, which can be SHA256withECDSA or SHA384withECDSA. This parameter is mandatory.
-keystoreFileKeystore file, which is mandatory in non-self-signed mode.
-keystorePwdKeystore password, which is optional.
-inFileOriginal ELF file, which is mandatory.
-outFileSigned file, which is mandatory.
-moduleFilePermission module.json file, which is optional.
-selfSignWhether the local self-signed mode is used. The value 1 indicates that the local self-signed mode is used, and the value 0 indicates that the certificate signature mode is used. The default value is 0. This parameter is optional.

Example

# Sign a binary file using a certificate.
binary-sign-tool sign -keyAlias "oh-app1-key-v1" -signAlg "SHA256withECDSA" -appCertFile "app1.pem" -profileFile "app1-profile.p7b" -profileSigned "1" -inFile "unsigned-elf" -keystoreFile "ohtest.p12" -outFile "signed-elf" -keyPwd "123456" -keystorePwd "123456" -moduleFile "module.json"
# Sign a binary file without a certificate.
binary-sign-tool sign -inFile "unsigned-elf" -outFile "signed-elf" -selfSign "1"
# Command output:
write code sign data success.

display-sign

Parameters

ParameterDescription
-inFileELF file, which is mandatory.

Example

# Print the certificate information of the binary file signature.
binary-sign-tool display-sign -inFile "signed-elf"
# Command output:
# Permission information output
# 1. No permission information
permission is not found
# 2. Output permission information
# Signature information output
# 1. No code signature.
code signature is not found
# 2. Self-signed mode.
code signature is self-sign
# 3. Output the signing certificate.

Error Message

FILE_NOT_FOUND

Description

When the command is executed, the error message "ERROR - FILE_NOT_FOUND, code: -102. Details: The'OpenHarmony.p12' file does not exist or the path is invalid, parameter name'-keystoreFile'" is displayed.

Possible Causes

The input file does not exist or the path is incorrect.

Solution

Check whether the input file path or file name is correct.

COMMAND_PARAM_ERROR

Description

When the command is executed, the error message "ERROR - COMMAND_PARAM_ERROR, code: -107. Details: 'generate-cert' Parameters error, Param key - value must in pairs" is displayed.

Possible Causes

  1. An unnecessary part is pasted in the command.
  2. The value of the last parameter is not entered.

Solution

Check and correct the unnecessary or incorrect part in the command.

KEY_PASSWORD_ERROR

Description

When the command is executed, the error message "ERROR - KEY_PASSWORD_ERROR, code: -114. Details: 'oh-app1-key-v1' keypair password error" is displayed.

Possible Causes

If the key pair password is incorrect, the KEY_PASSWORD_ERROR error occurs.

Solution

Check whether the password parameter in the command is correct. Ensure that the key pair password is correct when accessing different keystores.

NOT_SUPPORT_ERROR

Description

When the command is executed, the error message "ERROR - NOT_SUPPORT_ERROR, code: -104. Details: Not support file: ./OpenHarmony.p12" is displayed.

Possible Causes

The keystore file type is incorrect.

Solution

Ensure that the keystore file name extension is .p12.

KEY_ALIAS_ERROR

Description

When the command is executed, the error message "ERROR - KEY_ALIAS_ERROR, code: -109. Details: 'XXX' key alias already exists and cannot be generated repeatedly" is displayed.

Possible Causes

The key pair with the same alias already exists in the keystore.

Solution

Rename the alias of the key pair.

SIGN_ERROR

Description

After the command is executed, the error message "ERROR - SIGN_ERROR, code: -105. Details: No certificates configured for sign" is displayed.

Possible Causes

The signing key does not match the entity certificate.

Solution

  1. Check whether the keyAlias key is correct.
  2. Check whether the appCertFile is correct. Ensure that the key matches the certificate.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 acm-tool

openharmony 鸿蒙 network-cfg

openharmony 鸿蒙 devicedebug-tool

openharmony 鸿蒙 atm-tool

openharmony 鸿蒙 toybox

openharmony 鸿蒙 Readme-EN

openharmony 鸿蒙 unpacking-tool

openharmony 鸿蒙 cem-tool

openharmony 鸿蒙 packing-tool

openharmony 鸿蒙 app-check-tool

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/lN5PAQzg