Foreword
this article is based on Api13
after the previous two articles, we have obtained the key and certificate request file and the final release certificate and release Certificate Profile file. It can be said that we have completed all the signature information files. As the saying goes, everything is only due to Dongfeng. In this article, we will focus on how to configure the signature information and how to type the signature package.
In the previous two articles, the files we generated must be kept well. The most important are three files, namely cer certificate file,.p12 key file and. p7b release Certificate Profile file:
configure Signature Information
there are two ways to configure the signature information. One is to directly copy and modify the signature information according to the test information, and the other is to manually configure it through DevEco Studio IDE.
Copy Modifications
in the project build-profile.json5 file, we manually copy the signature information automatically generated by the original test, and change name to a name defined by ourselves, such as release. One more thing to know is that signingConfigs said before that it can support multiple signatures.
The configuration information can be set as follows:
the configuration code is as follows:
"signingConfigs": [
{
"name": "default",
"type": "HarmonyOS",
"material": {
"certpath": "/Users/abnerming/.ohos/config/default_Demo_Pnrx-7lyKAHsQo3AwkM12-Ly-9b8r6LaO9FjyL_MswI=.cer",
"storePassword": "0000001BC250F17B8DE65303700FBC807E84FB5489DA865BE094F95F1E7EADFE376F3586EB3AC142AB5E16",
"keyAlias": "debugKey",
"keyPassword": "0000001B5FEB0A1139B5C3D5CE59B37B9EB9100D28643C42ED6898619BCD4BEA36A821A666FC9AB0966217",
"profile": "/Users/abnerming/.ohos/config/default_Demo_Pnrx-7lyKAHsQo3AwkM12-Ly-9b8r6LaO9FjyL_MswI=.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "/Users/abnerming/.ohos/config/default_Demo_Pnrx-7lyKAHsQo3AwkM12-Ly-9b8r6LaO9FjyL_MswI=.p12"
}
},
{
"name": "release",
"type": "HarmonyOS",
"material": {
"storePassword": "00000018809D89A280116CD33A65E5D4F36AE7AFF512EFFB8AC497C2B63719E06B67A80A746C9F26",
"certpath": "/Users/abnerming/harmony/test/abner.cer",
"keyAlias": "abner",
"keyPassword": "00000018AB533C6359E2D430AF157ECCF736C800A54A66C82DDEA4357942EBAAB66A84CC4D72A952",
"profile": "/Users/abnerming/harmony/test/abner.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "/Users/abnerming/harmony/test/abner.p12"
}
}
]
for specific relevant fields, you can fill in one-to-one correspondence according to the table.
Project Configuration Manual Selection
As you can see from the above manual code modification, two items of storePassword and keyPassword are configured in the form of ciphertext, and you have to manually change the plaintext password to ciphertext. The encryption method also needs to be explored by yourself, which is very inconvenient. Don't panic. Manually selecting one item in the project configuration can solve our pain point. Click on the project configuration, select the Signing Configs option, and click the "+" option.
Enter your signature scheme name:
after clicking OK, cancel the Automatically generate signature option and fill it in manually. All the information is generated in the previous two articles. This information is very important. Please keep it well.
After the configuration is completed, we can find that the configured signature information is automatically generated in the project build-profile.json5 file, and of course, the converted ciphertext information is also included.
Configuration product category information
after the above signature information is configured, how do we package it? After all, we now have two sets of signature information, one is the default default and the other is the official release. How to choose, this requires configuring product category information, that is, the products field in the build-profile.json5.
If there is no other information configuration, we can directly copy a copy of default, name and signingConfig can be modified to correspond to our signature information.
"products": [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": "5.0.0(12)",
"runtimeOS": "HarmonyOS",
"buildOption": {
"strictMode": {
"caseSensitiveCheck": true,
"useNormalizedOHMUrl": true
}
}
},
{
"name": "release",
"signingConfig": "release",
"compatibleSdkVersion": "5.0.0(12)",
"runtimeOS": "HarmonyOS",
"buildOption": {
"strictMode": {
"caseSensitiveCheck": true,
"useNormalizedOHMUrl": true
}
}
}
]
Since the package needs to be signed and packaged for each module, after configuring the product category information, we need to add our category to each module. We must remember that each module needs to be added. Of course, the HAR module does not need to be configured.
For example, applyToProducts in the entry module, I have added new products here.
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default",
"release"
]
}
]
}
After the above information is configured, we can click the icon on the left side of the module to switch product categories.
If you want to type a formal package, you can directly select the configured formal signature.
Out of the package
after all the information is configured, packaging is the simplest. Click Build->Build Hap(s)/APP(s)->Build App(s) in the navigation bar at the top.
After clicking, after a period of compilation, a build folder will be generated in the project, and the corresponding signature information file will be found. The signature package with the signed field in it is typed.
Later, I went to the App Store and passed on this signature package.
This article tags: HarmonyOS application shelves.
Top comments (0)