1e41f4b71Sopenharmony_ci# hapsigner Guide 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Build 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**Java** 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci1. Check that Maven 3 of the correct version has been installed and configured. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci mvn -version 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci2. Download the code, open **developtools_hapsigner/hapsigntool**, and run the following command to build the package: 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci mvn package 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci You can find the binary file generated in the **./hap_sign_tool/target** directory. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**C++** 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci1. Build a signing tool for ohos-sdk. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci - Release version (default): 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci Run the **./build.sh --*product-name* ohos-sdk** command to build the signing tool for the release version. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci - Debug version: 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci In the **hapsigntool_cpp/BUILD.gn** file, add **defines = [ "SIGNATURE_LOG_DEBUG" ]**, and then run the build command **./build.sh --*product-name* ohos-sdk**. 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci2. Decompress **out/sdk/packages/ohos-sdk/ohos/toolchains-ohos-x64-xxx.zip**. 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci You can find the **hap-sign-tool** in the **lib** directory. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci## How to Development 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci### When to Use 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ciThe OpenHarmony system has a built-in KeyStore (KS) file named **OpenHarmony.p12**. This file contains the root CA certificate, intermediate CA certificate, and entity certificate information. The hapsigner tool signs OpenHarmony apps based on this file. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ciThe usage of hapsigner varies depending on whether an app signing certificate is available. 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci- If no signing certificate is available for your app, you can use this tool to generate a key pair for signing, generate an app signing certificate, sign the profile, and sign the app. 44e41f4b71Sopenharmony_ci- If a signing certificate is available for your app, you can directly sign the profile, and use the app signing certificate and the local KS file (containing the corresponding key) to sign your app. 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci### Command Description 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci1. Display command help information. 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci ``` 51e41f4b71Sopenharmony_ci -help # If no parameter is specified, the command help information is displayed by default. 52e41f4b71Sopenharmony_ci ``` 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci2. Display version information 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci ``` 57e41f4b71Sopenharmony_ci -version # Display the tool version information. 58e41f4b71Sopenharmony_ci ``` 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci3. Generate a key pair. 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci ``` 63e41f4b71Sopenharmony_ci generate-keypair: Generate a key pair. 64e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 65e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 66e41f4b71Sopenharmony_ci ├── -keyAlg # Key algorithm, which can be RSA or ECC. It is mandatory. 67e41f4b71Sopenharmony_ci ├── -keySize # Key length. It is mandatory. The key length is 2048, 3072, or 4096 bits for an RSA key and is NIST-P-256 or NIST-P-384 for an ECC key. 68e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory. 69e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 70e41f4b71Sopenharmony_ci ``` 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci4. Generate a CSR. 73e41f4b71Sopenharmony_ci ``` 74e41f4b71Sopenharmony_ci generate-csr: Generate a CSR. 75e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 76e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 77e41f4b71Sopenharmony_ci ├── -subject # Certificate subject. It is mandatory. 78e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withRSA, SHA384withRSA, SHA256withECDSA, or SHA384withECDSA. It is mandatory. 79e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory. 80e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 81e41f4b71Sopenharmony_ci ├── -outFile # CSR to generate. It is optional. If you do not specify this parameter, the CSR is output to the console. 82e41f4b71Sopenharmony_ci ``` 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci5. Generate a root CA or intermediate CA certificate. 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci ``` 87e41f4b71Sopenharmony_ci generate-ca: Generate a root CA or intermediate CA certificate. If there is no key, generate a key together with the certificate. 88e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 89e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 90e41f4b71Sopenharmony_ci ├── -keyAlg # Key algorithm, which can be RSA or ECC. It is mandatory. 91e41f4b71Sopenharmony_ci ├── -keySize # Key length. It is mandatory. The key length is 2048, 3072, or 4096 bits for an RSA key and is NIST-P-256 or NIST-P-384 for an ECC key. 92e41f4b71Sopenharmony_ci ├── -issuer # Issuer of the certificate. It is optional. It indicates a root CA certificate if not specified. 93e41f4b71Sopenharmony_ci ├── -issuerKeyAlias # Key alias of the issuer. It is optional. It indicates a root CA certificate if not specified. 94e41f4b71Sopenharmony_ci ├── -issuerKeyPwd # Key password of the issuer. It is optional. 95e41f4b71Sopenharmony_ci ├── -subject # Certificate subject. It is mandatory. 96e41f4b71Sopenharmony_ci ├── -validity # Validity period of the certificate. It is optional. The default value is 3650 days. 97e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withRSA, SHA384withRSA, SHA256withECDSA, or SHA384withECDSA. It is mandatory. 98e41f4b71Sopenharmony_ci ├── -basicConstraintsPathLen # Path length. It is optional. The default value is 0. 99e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory. 100e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 101e41f4b71Sopenharmony_ci ├── -issuerKeystoreFile # Issuer keystore file, which is optional. 102e41f4b71Sopenharmony_ci ├── -issuerKeystorePwd # KS password of the issuer. It is optional. 103e41f4b71Sopenharmony_ci ├── -outFile # File to generate. It is optional. The file is output to the console if this parameter is not specified. 104e41f4b71Sopenharmony_ci ``` 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci6. Generate a debug or release certificate for an app. 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci ``` 109e41f4b71Sopenharmony_ci generate-app-cert: Generate a debug or release certificate for an app. 110e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 111e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 112e41f4b71Sopenharmony_ci ├── -issuer # Issuer of the certificate. It is mandatory. 113e41f4b71Sopenharmony_ci ├── -issuerKeyAlias # Key alias of the issuer. It is mandatory. 114e41f4b71Sopenharmony_ci ├── -issuerKeyPwd # Key password of the issuer. It is optional. 115e41f4b71Sopenharmony_ci ├── -subject # Certificate subject. It is mandatory. 116e41f4b71Sopenharmony_ci ├── -validity # Validity period of the certificate. It is optional. The default value is 3650 days. 117e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withECDSA or SHA384withECDSA. 118e41f4b71Sopenharmony_ci ├── -issuerKeystoreFile # KS file of the issuer, in JKS or P12 format. It is optional. 119e41f4b71Sopenharmony_ci ├── -issuerKeystorePwd # KS password of the issuer. It is optional. 120e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory. 121e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 122e41f4b71Sopenharmony_ci ├── -outForm # Format of the certificate to generate. It is optional. The value can be cert or certChain. The default value is certChain. 123e41f4b71Sopenharmony_ci ├── -rootCaCertFile # Root CA certificate, which is mandatory when outForm is certChain. 124e41f4b71Sopenharmony_ci ├── -subCaCertFile # Intermediate CA certificate file, which is mandatory when outForm is certChain. 125e41f4b71Sopenharmony_ci ├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified. 126e41f4b71Sopenharmony_ci ``` 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci7. Generate a debug or release certificate for a profile. 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci ``` 131e41f4b71Sopenharmony_ci generate-profile-cert: Generate a debug or release certificate for a profile. 132e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 133e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 134e41f4b71Sopenharmony_ci ├── -issuer # Issuer of the certificate. It is mandatory. 135e41f4b71Sopenharmony_ci ├── -issuerKeyAlias # Key alias of the issuer. It is mandatory. 136e41f4b71Sopenharmony_ci ├── -issuerKeyPwd # Key password of the issuer. It is optional. 137e41f4b71Sopenharmony_ci ├── -subject # Certificate subject. It is mandatory. 138e41f4b71Sopenharmony_ci ├── -validity # Validity period of the certificate. It is optional. The default value is 3650 days. 139e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withECDSA or SHA384withECDSA. 140e41f4b71Sopenharmony_ci ├── -issuerKeystoreFile # KS file of the issuer, in JKS or P12 format. It is optional. 141e41f4b71Sopenharmony_ci ├── -issuerKeystorePwd # KS password of the issuer. It is optional. 142e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory. 143e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 144e41f4b71Sopenharmony_ci ├── -outForm # Format of the certificate to generate. It is optional. The value can be cert or certChain. The default value is certChain. 145e41f4b71Sopenharmony_ci ├── -rootCaCertFile # Root CA certificate, which is mandatory when outForm is certChain. 146e41f4b71Sopenharmony_ci ├── -subCaCertFile # Intermediate CA certificate file, which is mandatory when outForm is certChain. 147e41f4b71Sopenharmony_ci ├── -outFile # Certificate file (certificate or certificate chain) to generate. It is optional. The file is output to the console if this parameter is not specified. 148e41f4b71Sopenharmony_ci ``` 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci8. Generate a common certificate, which can be used to generate a custom certificate. 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci ``` 153e41f4b71Sopenharmony_ci generate-cert: Generate a common certificate, which can be used to generate a custom certificate. 154e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 155e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 156e41f4b71Sopenharmony_ci ├── -issuer # Issuer of the certificate. It is mandatory. 157e41f4b71Sopenharmony_ci ├── -issuerKeyAlias # Key alias of the issuer. It is mandatory. 158e41f4b71Sopenharmony_ci ├── -issuerKeyPwd # Key password of the issuer. It is optional. 159e41f4b71Sopenharmony_ci ├── -subject # Certificate subject. It is mandatory. 160e41f4b71Sopenharmony_ci ├── -validity # Validity period of the certificate. It is optional. The default value is 1095 days. 161e41f4b71Sopenharmony_ci ├── -keyUsage # Usages of the key. It is mandatory. The value can be one or more of digitalSignature, nonRepudiation, keyEncipherment, 162e41f4b71Sopenharmony_ci ├ dataEncipherment, keyAgreement, certificateSignature, crlSignature, 163e41f4b71Sopenharmony_ci ├ encipherOnly, and decipherOnly. Use a comma (,) to separate multiple values. 164e41f4b71Sopenharmony_ci ├── -keyUsageCritical # Whether keyUsage is a critical option. It is optional. The default value is true. 165e41f4b71Sopenharmony_ci ├── -extKeyUsage # Extended key usages. It is optional. The extended key usages include clientAuthentication, serverAuthentication, 166e41f4b71Sopenharmony_ci ├ codeSignature, emailProtection, smartCardLogin, timestamp, and ocspSignature. 167e41f4b71Sopenharmony_ci ├── -extKeyUsageCritical # Whether extKeyUsage is a critical option. It is optional. The default value is false. 168e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withRSA, SHA384withRSA, SHA256withECDSA, or SHA384withECDSA. It is mandatory. 169e41f4b71Sopenharmony_ci ├── -basicConstraints # Whether basicConstraints is contained. It is optional. The default value is false. 170e41f4b71Sopenharmony_ci ├── -basicConstraintsCritical # Whether basicConstraints is a critical option. It is optional. The default value is false. 171e41f4b71Sopenharmony_ci ├── -basicConstraintsCa # Whether it is CA. It is optional. The default value is false. 172e41f4b71Sopenharmony_ci ├── -basicConstraintsPathLen # Path length. It is optional. The default value is 0. 173e41f4b71Sopenharmony_ci ├── -issuerKeystoreFile # Issuer keystore file, which is optional. 174e41f4b71Sopenharmony_ci ├── -issuerKeystorePwd # KS password of the issuer. It is optional. 175e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory. 176e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 177e41f4b71Sopenharmony_ci ├── -outFile # Certificate file to generate. It is optional. The file is output to the console if this parameter is not specified. 178e41f4b71Sopenharmony_ci ``` 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci9. Sign a profile. 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci ``` 183e41f4b71Sopenharmony_ci sign-profile: Sign a profile. 184e41f4b71Sopenharmony_ci ├── -mode # Signing mode, which can be localSign or remoteSign. It is mandatory. 185e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 186e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 187e41f4b71Sopenharmony_ci ├── -profileCertFile # Profile signing certificate (certificate chain, in the entity certificate, intermediate CA certificate, and root certificate order). It is mandatory. 188e41f4b71Sopenharmony_ci ├── -inFile # Profile to be signed, in JSON format (developtools_hapsigner/autosign/UnsgnedReleasedProfileTemplate.json). It is mandatory. 189e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. 190e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory when mode is localSign. 191e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 192e41f4b71Sopenharmony_ci ├── -outFile # Signed profile to generate, in p7b format. This parameter is mandatory. 193e41f4b71Sopenharmony_ci ``` 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci10. Verify the signature of a profile. 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ci ``` 198e41f4b71Sopenharmony_ci verify-profile: Verify the profile signature. 199e41f4b71Sopenharmony_ci ├── -inFile # Signed profile in p7b format. This parameter is mandatory. 200e41f4b71Sopenharmony_ci ├── -outFile # Verification result file (containing the verification result and profile content), in JSON format. It is optional. The file is output to the console if this parameter is not specified. 201e41f4b71Sopenharmony_ci ``` 202e41f4b71Sopenharmony_ci 203e41f4b71Sopenharmony_ci11. Sign an app package or a debug tool. 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci ``` 206e41f4b71Sopenharmony_ci sign-app: Sign an app package or a binary tool. 207e41f4b71Sopenharmony_ci ├── -mode # Signing mode, which can be localSign, remoteSign, or remoteResign. It is mandatory. 208e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias. It is mandatory. 209e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. 210e41f4b71Sopenharmony_ci ├── -appCertFile # App signing certificate (certificate chain, in the entity certificate, intermediate CA certificate, and root certificate order). It is mandatory. 211e41f4b71Sopenharmony_ci ├── -profileFile # Name of the signed provisioning profile. When profileSigned is 1, the file is in p7b format. When profileSigned is 0, the file is in JSON format. This parameter is mandatory if an app package is to be signed, and optional if a binary tool is to be signed. 212e41f4b71Sopenharmony_ci ├── -profileSigned # Whether to sign the profile. The value 1 means to sign the profile, and value 0 means the opposite. The default value is 1. This parameter is optional. 213e41f4b71Sopenharmony_ci ├── -inForm # Format of the file to be signed. The value is zip for an app package in ZIP format, elf for a binary tool, and bin for an app package in BIN format. The default value is zip. This parameter is optional. 214e41f4b71Sopenharmony_ci ├── -inFile # File to be signed, which can be an app package, an elf file, or a bin file. This parameter is mandatory. 215e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. 216e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory when mode is localSign. 217e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. It is optional. 218e41f4b71Sopenharmony_ci ├── -outFile # Signed app package to generate. It is mandatory. 219e41f4b71Sopenharmony_ci ├── -signCode # Whether to enable code signing. The value 1 means to enable code signing, and the value 0 means the opposite. This parameter is optional. By default, code signing is enabled for .hap, .hsp, .hqf, and .elf files. To disable code signing, set this parameter to 0. 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ci ``` 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci12. Verify the signature of an app package or a debug tool. 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci ``` 226e41f4b71Sopenharmony_ci verify-app: Verify the signature of an app package or a binary tool. 227e41f4b71Sopenharmony_ci ├── -inFile # Signed file, which can be an app package, an elf file, or a bin file. This parameter is mandatory. 228e41f4b71Sopenharmony_ci ├── -outCertchain # Signed certificate chain file. It is mandatory. 229e41f4b71Sopenharmony_ci ├── -outProfile # Profile of the app. It is mandatory. 230e41f4b71Sopenharmony_ci ├── -inForm # Format of the file to be verified. The value is zip for an app package in ZIP format, elf for a binary tool, and bin for an app package in BIN format. The default value is zip. This parameter is optional. 231e41f4b71Sopenharmony_ci ``` 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ci### Signing Procedure 234e41f4b71Sopenharmony_ciThe process of signing an app package is as follows: 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci1. Generate a key pair for an app signing certificate. 237e41f4b71Sopenharmony_ci2. Generate an app signing certificate. 238e41f4b71Sopenharmony_ci3. Sign the profile. 239e41f4b71Sopenharmony_ci4. Sign the app package. 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci> **NOTE**<br> 243e41f4b71Sopenharmony_ci> 244e41f4b71Sopenharmony_ci> - For security purposes, use ECC to generate the key pair in step 1. Avoid using RSA. 245e41f4b71Sopenharmony_ci> - You are advised to place the app package to be signed, profile, **OpenHarmony.p12**, root CA certificate, intermediate CA certificate, and hapsigner in the same directory for easy operation. The following files are stored in [**developtools_hapsigner/autosign/result**](https://gitee.com/openharmony/developtools_hapsigner/tree/master/autosign/result):<br>- OpenHarmony keystore file **OpenHarmony.p12**<br>- Root CA certificate **rootCA.cer**<br>- intermediate CA certificate **subCA.cer**<br>- Profile signing certificate **OpenHarmonyProfileRelease.pem** 246e41f4b71Sopenharmony_ci 247e41f4b71Sopenharmony_ci1. **Generate a key pair for the app signing certificate.** 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci Generate a key pair for signing and save it to the KS. 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci Example (Java): 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci ```shell 254e41f4b71Sopenharmony_ci java -jar hap-sign-tool.jar generate-keypair -keyAlias "oh-app1-key-v1" -keyAlg "ECC" -keySize "NIST-P-256" -keystoreFile "OpenHarmony.p12" -keyPwd "123456" -keystorePwd "123456" 255e41f4b71Sopenharmony_ci ``` 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci Example (C++): 258e41f4b71Sopenharmony_ci 259e41f4b71Sopenharmony_ci ```shell 260e41f4b71Sopenharmony_ci hap-sign-tool generate-keypair -keyAlias "oh-app1-key-v1" -keyAlg "ECC" -keySize "NIST-P-256" -keystoreFile "OpenHarmony.p12" -keyPwd "123456" -keystorePwd "123456" 261e41f4b71Sopenharmony_ci ``` 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci > **NOTE** 264e41f4b71Sopenharmony_ci > 265e41f4b71Sopenharmony_ci > Record the **keyAlias**, **keyStorePwd**, and **keyPwd** values, which will be used when the app signing certificate is generated and the app package is signed. 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci The command parameters are described as follows: 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci ``` 270e41f4b71Sopenharmony_ci generate-keypair: Generate a key pair for the app signing certificate. 271e41f4b71Sopenharmony_ci ├── -keyAlias # Alias of the key used to generate the app signing certificate. It is stored in the OpenHarmony.p12 file. This parameter is mandatory. 272e41f4b71Sopenharmony_ci ├── -keyAlg # Key algorithm. It is mandatory. ECC is recommended. 273e41f4b71Sopenharmony_ci ├── -keySize # Key length. It is NIST-P-256 or NIST-P-384 for an ECC key. This parameter is mandatory. 274e41f4b71Sopenharmony_ci ├── -keyStoreFile # Keystore file, which is mandatory. You are advised to use OpenHarmony.p12. The Java version supports two formats: PKCS#12 and JKS. The C++ version supports PKCS#12 only. 275e41f4b71Sopenharmony_ci ├── -keyStorePwd # KS password. It is mandatory. The default password is 123456 for OpenHarmony.p12. 276e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. If this parameter is not specified, the generated key pair has no password. 277e41f4b71Sopenharmony_ci ``` 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci2. **Generate an app signing certificate.** 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci Use the local intermediate CA certificate to issue an app signing certificate. 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci Example (Java): 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci ```shell 286e41f4b71Sopenharmony_ci java -jar hap-sign-tool.jar generate-app-cert -keyAlias "oh-app1-key-v1" -signAlg "SHA256withECDSA" -issuer "C=CN,O=OpenHarmony,OU=OpenHarmony Team,CN= OpenHarmony Application CA" -issuerKeyAlias "openharmony application ca" -subject "C=CN,O=OpenHarmony,OU=OpenHarmony Team,CN=OpenHarmony Application Release" -keystoreFile "OpenHarmony.p12" -subCaCertFile "subCA.cer" -rootCaCertFile "rootCA.cer" -outForm "certChain" -outFile "app1.pem" -keyPwd "123456" -keystorePwd "123456" -issuerKeyPwd "123456" -validity "365" 287e41f4b71Sopenharmony_ci ``` 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci Example (C++): 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci ```shell 292e41f4b71Sopenharmony_ci hap-sign-tool generate-app-cert -keyAlias "oh-app1-key-v1" -signAlg "SHA256withECDSA" -issuer "C=CN,O=OpenHarmony,OU=OpenHarmony Team,CN= OpenHarmony Application CA" -issuerKeyAlias "openharmony application ca" -subject "C=CN,O=OpenHarmony,OU=OpenHarmony Team,CN=OpenHarmony Application Release" -keystoreFile "OpenHarmony.p12" -subCaCertFile "subCA.cer" -rootCaCertFile "rootCA.cer" -outForm "certChain" -outFile "app1.pem" -keyPwd "123456" -keystorePwd "123456" -issuerKeyPwd "123456" -validity "365" 293e41f4b71Sopenharmony_ci ``` 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci The command parameters are described as follows: 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci ``` 298e41f4b71Sopenharmony_ci generate-app-cert: Generate an app signing certificate. 299e41f4b71Sopenharmony_ci ├── -keyAlias # Key alias, which must be the same as that in the previous step. 300e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. 301e41f4b71Sopenharmony_ci ├── -issuer # Issuer of the certificate. Enter the issuer of the intermediate CA certificate. It is mandatory and cannot be changed. 302e41f4b71Sopenharmony_ci ├── -issuerKeyAlias #Alias of the issuer key. Enter the alias of the intermediate CA certificate key. This parameter is mandatory and cannot be changed. 303e41f4b71Sopenharmony_ci ├── -subject # Subject of the certificate. Enter the subject in the same sequence specified in the command. This parameter is mandatory. 304e41f4b71Sopenharmony_ci ├── -issuerKeyPwd # Key password of the issuer. Enter the key password of the intermediate CA certificate. It is mandatory and cannot be changed. In this example, it is 123456. 305e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory and cannot be changed. You are advised to use OpenHarmony.p12. The Java version supports two formats: PKCS#12 and JKS. The C++ version supports PKCS#12 only. 306e41f4b71Sopenharmony_ci ├── -rootCaCertFile # Root CA certificate. It is mandatory and cannot be changed. 307e41f4b71Sopenharmony_ci ├── -subCaCertFile # Intermediate CA certificate provided. This parameter is mandatory and cannot be modified. 308e41f4b71Sopenharmony_ci ├── -outForm # Format of the certificate file to generate. certChain is recommended. 309e41f4b71Sopenharmony_ci ├── -outFile # File to generate. It is optional. The file is output to the console if this parameter is not specified. 310e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. It is optional. It is the key password set when the key pair is generated. 311e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. The default value is 123456. 312e41f4b71Sopenharmony_ci ├── -validity # Validity period of the certificate. It is optional. The default value is 3650 days. 313e41f4b71Sopenharmony_ci ``` 314e41f4b71Sopenharmony_ci 315e41f4b71Sopenharmony_ci3. **Sign the profile.** 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci Call the profile signing API to sign the profile using the profile signing key. 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci Example (Java): 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ci ```shell 322e41f4b71Sopenharmony_ci java -jar hap-sign-tool.jar sign-profile -keyAlias "openharmony application profile release" -signAlg "SHA256withECDSA" -mode "localSign" -profileCertFile "OpenHarmonyProfileRelease.pem" -inFile "UnsgnedReleasedProfileTemplate.json" -keystoreFile "OpenHarmony.p12" -outFile "app1-profile.p7b" -keyPwd "123456" -keystorePwd "123456" 323e41f4b71Sopenharmony_ci ``` 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci Example (C++): 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci ```shell 328e41f4b71Sopenharmony_ci hap-sign-tool sign-profile -keyAlias "openharmony application profile release" -signAlg "SHA256withECDSA" -mode "localSign" -profileCertFile "OpenHarmonyProfileRelease.pem" -inFile "UnsgnedReleasedProfileTemplate.json" -keystoreFile "OpenHarmony.p12" -outFile "app1-profile.p7b" -keyPwd "123456" -keystorePwd "123456" 329e41f4b71Sopenharmony_ci ``` 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci The command parameters are described as follows: 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ci ``` 334e41f4b71Sopenharmony_ci sign-profile: Sign a profile. 335e41f4b71Sopenharmony_ci ├── -keyAlias # Alias of the key for generating the profile certificate. It is mandatory and cannot be changed. 336e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. 337e41f4b71Sopenharmony_ci ├── -mode # Signing mode, which must be localSign. It is mandatory. 338e41f4b71Sopenharmony_ci ├── -profileCertFile # Profile signing certificate. Use the certificate provided. It is mandatory and cannot be changed. 339e41f4b71Sopenharmony_ci ├── -inFile # Profile to be signed, in JSON format (developtools_hapsigner/autosign/UnsgnedReleasedProfileTemplate.json). It is mandatory. 340e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory and cannot be changed. You are advised to use OpenHarmony.p12. The Java version supports two formats: PKCS#12 and JKS. The C++ version supports PKCS#12 only. 341e41f4b71Sopenharmony_ci ├── -outFile # Signed profile to generate, in p7b format. This parameter is mandatory. 342e41f4b71Sopenharmony_ci ├── -keyPwd # Key password. The default key password in OpenHarmony.p12 is 123456. 343e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password. The default key password in OpenHarmony.p12 is 123456. 344e41f4b71Sopenharmony_ci ``` 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci4. **Sign the app package.** 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci Sign the app package with the app signing key. 349e41f4b71Sopenharmony_ci 350e41f4b71Sopenharmony_ci Example (Java): 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci ```shell 353e41f4b71Sopenharmony_ci java -jar hap-sign-tool.jar sign-app -keyAlias "oh-app1-key-v1" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "app1.pem" -profileFile "app1-profile.p7b" -inFile "app1-unsigned.zip" -keystoreFile "OpenHarmony.p12" -outFile "app1-signed.hap" -keyPwd "123456" -keystorePwd "123456" 354e41f4b71Sopenharmony_ci ``` 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ci Example (C++): 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci ```shell 359e41f4b71Sopenharmony_ci hap-sign-tool sign-app -keyAlias "oh-app1-key-v1" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "app1.pem" -profileFile "app1-profile.p7b" -inFile "app1-unsigned.zip" -keystoreFile "OpenHarmony.p12" -outFile "app1-signed.hap" -keyPwd "123456" -keystorePwd "123456" 360e41f4b71Sopenharmony_ci ``` 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci > **NOTE** 363e41f4b71Sopenharmony_ci > 364e41f4b71Sopenharmony_ci > The following parameters are used when there is no app signing certificate available. If the app signing certificate is available, the following parameters must be modified: 365e41f4b71Sopenharmony_ci > -**keyAlias**: Enter the key alias of the app signing certificate. This parameter is mandatory. <br/> 366e41f4b71Sopenharmony_ci > -**appCertFile**: Enter the app signing certificate. This parameter is mandatory.<br/> 367e41f4b71Sopenharmony_ci > -**keystoreFile**: Enter the KS file of the app signing certificate. This parameter is mandatory. <br/> 368e41f4b71Sopenharmony_ci > -**keyPwd**: Enter the key password in the KS file. <br/> 369e41f4b71Sopenharmony_ci > -**keystorePwd**: Enter the KS password in the KS file. 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci The command parameters are described as follows: 372e41f4b71Sopenharmony_ci 373e41f4b71Sopenharmony_ci ``` 374e41f4b71Sopenharmony_ci sign-app: Sign an app package. 375e41f4b71Sopenharmony_ci ├──-keyAlias # Key alias, which must be the same as the alias of the key pair generated. This parameter is mandatory. 376e41f4b71Sopenharmony_ci ├── -signAlg # Signing algorithm, which can be SHA256withECDSA or SHA384withECDSA. It is mandatory. 377e41f4b71Sopenharmony_ci ├── -mode # Signing mode, which must be localSign. It is mandatory. 378e41f4b71Sopenharmony_ci ├── -appCertFile # App signing certificate (certificate chain, in the entity certificate, intermediate CA certificate, and root certificate order). Enter the app signing certificate generated in step 2. This parameter is mandatory. 379e41f4b71Sopenharmony_ci ├── -profileFile # Signed profile in p7b format. Enter the profile generated. This parameter is mandatory. 380e41f4b71Sopenharmony_ci ├── -inFile # App package to be signed. This parameter is mandatory. 381e41f4b71Sopenharmony_ci ├── -keystoreFile # Keystore file, which is mandatory and cannot be changed. The value must be the same as that in step 1. The Java version supports two formats: PKCS#12 and JKS. The C++ version supports PKCS#12 only. 382e41f4b71Sopenharmony_ci ├── -outFile # Signed file to generate. It is mandatory. 383e41f4b71Sopenharmony_ci ├── -keyPwd # Key password, which must be the actual key password. 384e41f4b71Sopenharmony_ci ├── -keystorePwd # KS password, which must be the actual KS password. 385e41f4b71Sopenharmony_ci ``` 386e41f4b71Sopenharmony_ci 387e41f4b71Sopenharmony_ci## FAQs (Java) 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci1. The console displays the app signing certificate generated but no file is output. 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci - **Symptom** 392e41f4b71Sopenharmony_ci 393e41f4b71Sopenharmony_ci When the tool is used to generate an app signing certificate, the certificate content is displayed on the console but no certificate is generated. 394e41f4b71Sopenharmony_ci 395e41f4b71Sopenharmony_ci - **Possible Causes** 396e41f4b71Sopenharmony_ci 397e41f4b71Sopenharmony_ci The path specified by **outFile** is incorrect, or the hyphen (-) in **-outFile** is not an English character. 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ci - **Solution** 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ci Check and correct the value of **outFile**, and ensure the hyphen (-) in **-outFile** is an English character. 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci2. Failed to sign a profile. 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci - **Symptom** 406e41f4b71Sopenharmony_ci 407e41f4b71Sopenharmony_ci When the tool is used to sign a profile, any of the following information is displayed: 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_ci (1) SIGN_ERROR, code: 107. Details: Failed to verify signature: Wrong key usage 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci (2) NOT_SUPPORT_ERROR, code: 105. Details: Profile cert 'result\profile1.pem' must a cert chain 412e41f4b71Sopenharmony_ci 413e41f4b71Sopenharmony_ci (3) VERIFY_ERROR, code: 108. Details: Failed to verify signature: unable to find valid certification path to requested target 414e41f4b71Sopenharmony_ci 415e41f4b71Sopenharmony_ci - **Possible Causes** 416e41f4b71Sopenharmony_ci 417e41f4b71Sopenharmony_ci (1) The certificate chain of the profile signing certificate is in incorrect order. 418e41f4b71Sopenharmony_ci 419e41f4b71Sopenharmony_ci (2) The profile signing certificate is not a certificate chain. 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_ci (3) The certificate subject is in incorrect sequence, or the **-issuerKeyAlias** parameter set to generate the app signing certificate is incorrect. 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ci - **Solution** 424e41f4b71Sopenharmony_ci 425e41f4b71Sopenharmony_ci (1) Check that the certificates in the certificate chain are in ascending or descending order of seniority. 426e41f4b71Sopenharmony_ci 427e41f4b71Sopenharmony_ci (2) Check that the certificate is a certificate chain. 428e41f4b71Sopenharmony_ci 429e41f4b71Sopenharmony_ci (3) Check that the certificate subject is in the C, O, OU, and CN order. 430e41f4b71Sopenharmony_ci 431e41f4b71Sopenharmony_ci3. Incorrect SignAlg is displayed when an app package is signed. 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci - **Symptom** 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci The following information is displayed after the command is executed:<br>NOT_SUPPORT_ERROR, code: 105. Details: SignAlg params is incorrect, signature algorithms include SHA256withECDSA,SHA384withECDSA 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ci - **Possible Causes** 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci The signing algorithm is not supported. Check the value of **signAlg**. 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_ci - **Solution** 442e41f4b71Sopenharmony_ci 443e41f4b71Sopenharmony_ci Use ECC to generate the key pair for an app or profile signing certificate. Use SHA256withECDSA or SHA384withECDSA as the app signing algorithm. 444e41f4b71Sopenharmony_ci 445e41f4b71Sopenharmony_ci4. Failed to sign an app package because CN of the certificate is empty. 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_ci - **Symptom** 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci The message "error: Common name of certificate is empty!" is displayed. 450e41f4b71Sopenharmony_ci 451e41f4b71Sopenharmony_ci - **Possible Causes** 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci The app signing certificate used does not contain the CN field. 454e41f4b71Sopenharmony_ci 455e41f4b71Sopenharmony_ci - **Solution** 456e41f4b71Sopenharmony_ci 457e41f4b71Sopenharmony_ci The CN field of the app signing certificate cannot be empty. Generate a certificate in correct format. 458e41f4b71Sopenharmony_ci 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci## FAQs (C++) 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci> **NOTE** 463e41f4b71Sopenharmony_ci> 464e41f4b71Sopenharmony_ci> The numbers in **Symptom**, **Possible Causes**, and **Solution** are in one-to-one correspondence. 465e41f4b71Sopenharmony_ci 466e41f4b71Sopenharmony_ci1. Command parameter errors 467e41f4b71Sopenharmony_ci 468e41f4b71Sopenharmony_ci + **Symptom** 469e41f4b71Sopenharmony_ci 470e41f4b71Sopenharmony_ci (1) Error message: ERROR - COMMAND_PARAM_ERROR, code: -107.Details: 'generate-cert' Parameters error, Param key - value must in pairs 471e41f4b71Sopenharmony_ci 472e41f4b71Sopenharmony_ci (2) Error message: ERROR - KEY_PASSWORD_ERROR, code: -114.Details: 'oh-app1-key-v1' keypair password error 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ci (3) Error message: ERROR - NOT_SUPPORT_ERROR, code: -104.Details: Not support file: ./OpenHarmony.p1 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ci (4) Error message: ERROR - KEY_ALIAS_ERROR, code: -109.Details: 'XXX' key alias already exists and cannot be generated repeatedly 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ci + **Possible Causes** 479e41f4b71Sopenharmony_ci 480e41f4b71Sopenharmony_ci (1) Extra command parameter is pasted, or the last parameter of the command is not specified. 481e41f4b71Sopenharmony_ci 482e41f4b71Sopenharmony_ci (2) The the password of the key pair entered is incorrect. 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ci (3) The keystore file type specified is incorrect. 485e41f4b71Sopenharmony_ci 486e41f4b71Sopenharmony_ci (4) The key pair with the same alias already exists in the keystore. 487e41f4b71Sopenharmony_ci 488e41f4b71Sopenharmony_ci + **Solution** 489e41f4b71Sopenharmony_ci 490e41f4b71Sopenharmony_ci (1) Check for redundant or incorrect parameters and correct them. 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci (2) Enter the correct password. 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci (3) Check that the keystore file name extension is .p12 or .jks. 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ci (4) Rename the alias of the key pair. 497e41f4b71Sopenharmony_ci 498e41f4b71Sopenharmony_ci2. Errors reported after the command for generating an app signing certificate is executed 499e41f4b71Sopenharmony_ci 500e41f4b71Sopenharmony_ci - **Symptom** 501e41f4b71Sopenharmony_ci 502e41f4b71Sopenharmony_ci (1) Error message: ERROR - KEY_ALIAS_ERROR, code: -109.Details: keyAlias: 'oh-app1-key-v2' is not exist in/mnt/d/file/Test_0528/OpenHarmony.p12 503e41f4b71Sopenharmony_ci 504e41f4b71Sopenharmony_ci (2) Error message: ERROR - KEYSTORE_PASSWORD_ERROR, code: -115.Details: keyStore password error 505e41f4b71Sopenharmony_ci 506e41f4b71Sopenharmony_ci (3) Error message: ERROR - KEY_PASSWORD_ERROR, code: -114.Details: 'oh-app-sign-srv-ca-key-v1' keypair password error 507e41f4b71Sopenharmony_ci 508e41f4b71Sopenharmony_ci - **Possible Causes** 509e41f4b71Sopenharmony_ci 510e41f4b71Sopenharmony_ci (1) The specified key alias cannot be found in the keystore. 511e41f4b71Sopenharmony_ci 512e41f4b71Sopenharmony_ci (2) The keystore password is incorrect. 513e41f4b71Sopenharmony_ci 514e41f4b71Sopenharmony_ci (3) The password of the key pair is specified when the intermediate CA certificate of the app is generated, but the **-issuerKeyPwd** parameter is not entered when the debug certificate of the app is generated. 515e41f4b71Sopenharmony_ci 516e41f4b71Sopenharmony_ci - **Solution** 517e41f4b71Sopenharmony_ci 518e41f4b71Sopenharmony_ci (1) Check that the key alias is the same as that entered when the key pair is generated. 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci (2) Check that the keystore password is the same as that entered when the key pair is generated. 521e41f4b71Sopenharmony_ci 522e41f4b71Sopenharmony_ci (3) Check that **-issuerKeyPwd** is specified when the profile is generated, and that the value is the same as the password of the key pair when the intermediate CA certificate of the profile is generated. 523e41f4b71Sopenharmony_ci 524e41f4b71Sopenharmony_ci3. Errors reported when the profile is executed for signing 525e41f4b71Sopenharmony_ci 526e41f4b71Sopenharmony_ci - **Symptom** 527e41f4b71Sopenharmony_ci 528e41f4b71Sopenharmony_ci (1) Error message: ERROR - PROVISION_INVALID, code: 0.Details: Tag app-distribution-type is empty 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_ci (2) Error message: VERIFY_ERROR, code: -106.Details: Failed to verify signature: unable to find valid certification path to requested target 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci - **Possible Causes** 533e41f4b71Sopenharmony_ci 534e41f4b71Sopenharmony_ci (1) The certificate subject is in incorrect sequence, or the **-issuerKeyAlias** parameter set to generate the app signing certificate is incorrect. 535e41f4b71Sopenharmony_ci 536e41f4b71Sopenharmony_ci (2) The value of **type** in **profile.json** does not match the value of **key** in **bundle_info**. The typ **debug** corresponds to **development-certificate**, and **release** to **distribution-certificate**. 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci - **Solution** 539e41f4b71Sopenharmony_ci 540e41f4b71Sopenharmony_ci (1) Check that the certificate subject is in the C, O, OU, and CN order. 541e41f4b71Sopenharmony_ci 542e41f4b71Sopenharmony_ci (2) Check that the configuration in the **bundle.json** file is correct. 543e41f4b71Sopenharmony_ci 544e41f4b71Sopenharmony_ci4. Errors reported when an app is signed 545e41f4b71Sopenharmony_ci 546e41f4b71Sopenharmony_ci - **Symptom** 547e41f4b71Sopenharmony_ci 548e41f4b71Sopenharmony_ci (1) Error message: ERROR - PROVISION_INVALID, code: 0.Details: Require build type must be debug or release 549e41f4b71Sopenharmony_ci 550e41f4b71Sopenharmony_ci (2) Error message: ERROR - ZIP_ERROR, code: -111. Details: zip init failed 551e41f4b71Sopenharmony_ci 552e41f4b71Sopenharmony_ci (3) Error message: ERROR - SIGN_ERROR, code: -105.Details: No certificates configured for sign 553e41f4b71Sopenharmony_ci 554e41f4b71Sopenharmony_ci - **Possible Causes** 555e41f4b71Sopenharmony_ci 556e41f4b71Sopenharmony_ci (1) The profile is not signed (no .p7b file is generated). Before the HAP is signed, the profile does not contain the **type** parameter. 557e41f4b71Sopenharmony_ci 558e41f4b71Sopenharmony_ci (2) The size of the .zip package exceeds 4 GB. The change in the format of the compressed file causes a decompression failure. 559e41f4b71Sopenharmony_ci 560e41f4b71Sopenharmony_ci (3) The key used for signing does not match the entity certificate. 561e41f4b71Sopenharmony_ci 562e41f4b71Sopenharmony_ci - **Solution** 563e41f4b71Sopenharmony_ci 564e41f4b71Sopenharmony_ci (1) Before using an unsigned profile file to sign the HAP, add **type** with the value of **debug** or **release** in the **profile.json** file. 565e41f4b71Sopenharmony_ci 566e41f4b71Sopenharmony_ci (2) If the HAP to be signed exceeds 4 GB, split it into smaller ones. 567e41f4b71Sopenharmony_ci 568e41f4b71Sopenharmony_ci (3) Check **keyAlias** and **appCertFile** and ensure the key used for signing matches the certificate. 569e41f4b71Sopenharmony_ci 570e41f4b71Sopenharmony_ci5. HAP installation failure 571e41f4b71Sopenharmony_ci 572e41f4b71Sopenharmony_ci - **Symptom** 573e41f4b71Sopenharmony_ci 574e41f4b71Sopenharmony_ci (1) When a .json file of the release or debug type is used to sign and install a HAP, the following information is displayed: device type is not supports 575e41f4b71Sopenharmony_ci 576e41f4b71Sopenharmony_ci (2) When a .json file of the debug type is used to install a HAP, the following information is displayed: verify pkcs7 info failed 577e41f4b71Sopenharmony_ci 578e41f4b71Sopenharmony_ci (3) When a HAP is installed on an OpenHarmony system of an earlier version, the following information is displayed: install sign info inconsistent 579e41f4b71Sopenharmony_ci 580e41f4b71Sopenharmony_ci (4) When a signed HAP is installed, the following information is displayed: "signature verification failed due to not trusted app source." 581e41f4b71Sopenharmony_ci 582e41f4b71Sopenharmony_ci - **Possible Causes** 583e41f4b71Sopenharmony_ci 584e41f4b71Sopenharmony_ci (1) The OpenHarmony system configuration file does not support the device type of the HAP. 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ci (2) The **device-ids** field in the .json file of the debug type does not contain your device **udid**. 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ci (3) The HAP with the same name has been installed. 589e41f4b71Sopenharmony_ci 590e41f4b71Sopenharmony_ci (4) The certificate in the .json file of the debug or release type is not a trusted certificate. 591e41f4b71Sopenharmony_ci 592e41f4b71Sopenharmony_ci - **Solution** 593e41f4b71Sopenharmony_ci 594e41f4b71Sopenharmony_ci (1) Run the **hdc shell param get const.product.devicetype** command to check the device types supported by the system and replace the HAP based on the device type. 595e41f4b71Sopenharmony_ci 596e41f4b71Sopenharmony_ci (2) Run the **hdc shell bm get --udid** command to obtain the UDID of the device and add it to **device-ids** in the .json file of the debug type. 597e41f4b71Sopenharmony_ci 598e41f4b71Sopenharmony_ci (3) Run the **bm uninstall -n *Bundle_name*** command to uninstall the HAP with the same name. 599e41f4b71Sopenharmony_ci 600e41f4b71Sopenharmony_ci (4) Check whether an incorrect .json file is used. 601