1e41f4b71Sopenharmony_ci# @ohos.security.certManager (Certificate Management)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **certManager** module provides system-level certificate management capabilities to ensure secure use and management of certificates throughout their lifecycle (installation, storage, use, and destruction).
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Modules to Import
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci```ts
12e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
13e41f4b71Sopenharmony_ci```
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## CmKeyPurpose
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciEnumerates the purposes of using the key.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci| Name      | Value|  Description     |
22e41f4b71Sopenharmony_ci| ---------- | ------ | --------- |
23e41f4b71Sopenharmony_ci| CM_KEY_PURPOSE_SIGN | 4      | The key is used for signing.|
24e41f4b71Sopenharmony_ci| CM_KEY_PURPOSE_VERIFY | 8      | The key is used for signature verification.|
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci## CmKeyDigest
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ciEnumerates the digest algorithms that can be used for signing and signature verification.
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci| Name      | Value|  Description     |
33e41f4b71Sopenharmony_ci| ---------- | ------ | --------- |
34e41f4b71Sopenharmony_ci| CM_DIGEST_NONE | 0      | No digest algorithm is required. If this option is used, the service needs to pass in the data with the digest generated for signing or signature verification.|
35e41f4b71Sopenharmony_ci| CM_DIGEST_MD5 | 1      | MD5.|
36e41f4b71Sopenharmony_ci| CM_DIGEST_SHA1 | 2      | SHA-1.|
37e41f4b71Sopenharmony_ci| CM_DIGEST_SHA224 | 3      | SHA-224.|
38e41f4b71Sopenharmony_ci| CM_DIGEST_SHA256 | 4      | SHA-256.|
39e41f4b71Sopenharmony_ci| CM_DIGEST_SHA384 | 5      | SHA-384.|
40e41f4b71Sopenharmony_ci| CM_DIGEST_SHA512 | 6      | SHA-512.|
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci## CmKeyPadding
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ciEnumerates the padding modes that can be used for signing and signature verification.
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci| Name      | Value|  Description     |
49e41f4b71Sopenharmony_ci| ---------- | ------ | --------- |
50e41f4b71Sopenharmony_ci| CM_PADDING_NONE | 0      | No padding.|
51e41f4b71Sopenharmony_ci| CM_PADDING_PSS | 1      | PSS.|
52e41f4b71Sopenharmony_ci| CM_PADDING_PKCS1_V1_5 | 2      | PKCS1-V1_5.|
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci## CMSignatureSpec
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ciRepresents a set of parameters used for signing or signature verification, including the key usage purpose, padding mode, and digest algorithm.
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci| Name          | Type                             | Read-Only| Optional| Description                                                        |
61e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ------------------------------------------------------------ | ------------------------------------------------------------ |
62e41f4b71Sopenharmony_ci| purpose          | [CmKeyPurpose](#cmkeypurpose)                       | No | No | Purpose of using the key.|
63e41f4b71Sopenharmony_ci| padding        | [CmKeyPadding](#cmkeypadding)                       | No  | Yes | Padding mode.|
64e41f4b71Sopenharmony_ci| digest        | [CmKeyDigest](#cmkeydigest)                       | No  | Yes | Digest algorithm.|
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci## CertInfo
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ciRepresents detailed information about a certificate.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci| Name          | Type                             | Read-Only| Optional| Description                                                        |
74e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ |
75e41f4b71Sopenharmony_ci| uri          | string         | No  | No | Unique identifier of the certificate.|
76e41f4b71Sopenharmony_ci| certAlias          | string   | No | No | Alias of the certificate.|
77e41f4b71Sopenharmony_ci| state          | boolean     | No | No | Certificate state. The value **true** indicates that the certificate is enabled, and **false** means the opposite.|
78e41f4b71Sopenharmony_ci| issuerName          | string         | No | No | Issuer of the certificate.|
79e41f4b71Sopenharmony_ci| subjectName          | string   | No | No | User of the certificate.|
80e41f4b71Sopenharmony_ci| serial          | string     | No | No | Serial number of the certificate.|
81e41f4b71Sopenharmony_ci| notBefore          | string         | No | No | Date from which the certificate takes effect.|
82e41f4b71Sopenharmony_ci| notAfter          | string   | No | No | Date when the certificate expires.|
83e41f4b71Sopenharmony_ci| fingerprintSha256     | string     | No | No | Fingerprint value of the certificate.|
84e41f4b71Sopenharmony_ci| cert          | Uint8Array         | No | No | Certificate data in binary format.|
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci## CertAbstract
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciRepresents brief information about a certificate.
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| Name          | Type                             | Read-Only| Optional| Description                                                        |
93e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ |
94e41f4b71Sopenharmony_ci| uri          | string         | No | No | Unique identifier of the certificate.|
95e41f4b71Sopenharmony_ci| certAlias          | string   | No | No | Alias of the certificate.|
96e41f4b71Sopenharmony_ci| state          | boolean     | No | No | Certificate state. The value **true** indicates that the certificate is enabled, and **false** means the opposite.|
97e41f4b71Sopenharmony_ci| issuerName          | string         | No | No | Issuer of the certificate.|
98e41f4b71Sopenharmony_ci| subjectName          | string   | No | No | User of the certificate.|
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci## Credential
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ciRepresents detailed information about a credential.
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci| Name          | Type                             | Read-Only| Optional| Description                                                        |
107e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ |
108e41f4b71Sopenharmony_ci| type          | string         | No | No | Type of the credential.|
109e41f4b71Sopenharmony_ci| alias          | string   | No | No | Alias of the credential.|
110e41f4b71Sopenharmony_ci| keyUri          | string     | No | No | Unique identifier of the credential.|
111e41f4b71Sopenharmony_ci| certNum          | number         | No | No | Number of certificates contained in the credential.|
112e41f4b71Sopenharmony_ci| keyNum          | number   | No | No | Number of keys contained in the credential.|
113e41f4b71Sopenharmony_ci| credentialData          | Uint8Array   | No | No | Credential data in binary format.|
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci## CredentialAbstract
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ciRepresents brief information about a credential.
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci| Name          | Type                             | Read-Only| Optional| Description                                                        |
122e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ |
123e41f4b71Sopenharmony_ci| type          | string         | No| No | Type of the credential.|
124e41f4b71Sopenharmony_ci| alias          | string   | No | No | Alias of the credential.|
125e41f4b71Sopenharmony_ci| keyUri          | string     | No | No | Unique identifier of the credential.|
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci## CMResult
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ciRepresents the result returned.
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci| Name          | Type                             | Read-Only| Optional| Description                                                        |
134e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ |
135e41f4b71Sopenharmony_ci| certList          | Array<[CertAbstract](#certabstract)> | No | Yes  | Brief certificate information.|
136e41f4b71Sopenharmony_ci| certInfo          | [CertInfo](#certinfo) | No | Yes  | Detailed certificate information.|
137e41f4b71Sopenharmony_ci| credentialList          | Array<[CredentialAbstract](#credentialabstract)> | No | Yes  | Brief credential information.|
138e41f4b71Sopenharmony_ci| credential         | [Credential](#credential) | No | Yes  | Detailed credential information.|
139e41f4b71Sopenharmony_ci| appUidList        | Array\<string>     | No | Yes  | List of authorized applications.|
140e41f4b71Sopenharmony_ci| uri         | string    | No | Yes  | Unique identifier of the certificate or credential.|
141e41f4b71Sopenharmony_ci| outData         | Uint8Array    | No | Yes  | Signature generated.|
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci## CMHandle
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciRepresents the handle to a signing or signature verification operation.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci| Name          | Type                             | Read-Only| Optional| Description                                                        |
150e41f4b71Sopenharmony_ci| -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ |
151e41f4b71Sopenharmony_ci| handle         | Uint8Array        | No | No  | Handle returned by **certManager.init()** for the subsequent signing or signature verification operation. |
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci## CMErrorCode
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ciEnumerates the error codes used in the certificate management APIs.
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci| Name      | Value|  Description     |
160e41f4b71Sopenharmony_ci| ---------- | ------ | --------- |
161e41f4b71Sopenharmony_ci| CM_ERROR_NO_PERMISSION   | 201      | The application does not have the permission to call the API.|
162e41f4b71Sopenharmony_ci| CM_ERROR_INVALID_PARAMS   | 401      | Invalid input parameter is found.|
163e41f4b71Sopenharmony_ci| CM_ERROR_GENERIC  | 17500001      | An internal error occurs when the interface is called.|
164e41f4b71Sopenharmony_ci| CM_ERROR_NO_FOUND  | 17500002      | The certificate or credential does not exist.|
165e41f4b71Sopenharmony_ci| CM_ERROR_INCORRECT_FORMAT  | 17500003      | The certificate or credential is in invalid format.|
166e41f4b71Sopenharmony_ci| CM_ERROR_MAX_CERT_COUNT_REACHED<sup>12+</sup>  | 17500004      | The number of certificates or credentials has reached the limit.|
167e41f4b71Sopenharmony_ci| CM_ERROR_NO_AUTHORIZATION<sup>12+</sup>  | 17500005      | The application has not obtained user authorization.|
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci## certificateManager.installPrivateCertificate
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ciinstallPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string, callback: AsyncCallback\<CMResult>): void
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ciInstalls a private credential. This API uses an asynchronous callback to return the result.
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci**Parameters**
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
182e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
183e41f4b71Sopenharmony_ci| keystore | Uint8Array                   | Yes  | Keystore file containing the key pair and certificate.|
184e41f4b71Sopenharmony_ci| keystorePwd | string | Yes  | Password of the keystore file. The password cannot exceed 32 bytes.|
185e41f4b71Sopenharmony_ci| certAlias | string | Yes  | Credential alias. Currently, the alias can contain only digits, letters, and underscores (_) and should not exceed 32 bytes.|
186e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[CMResult](#cmresult)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is **uri** in the [CMResult](#cmresult) object. Otherwise, **err** is an error object.|
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci**Error codes**
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
193e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
194e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
195e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
196e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
197e41f4b71Sopenharmony_ci| 17500003 | The keystore is in an invalid format or the keystore password is incorrect. |
198e41f4b71Sopenharmony_ci| 17500004<sup>12+</sup> | The number of certificates or credentials reaches the maximum allowed. |
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**Example**
201e41f4b71Sopenharmony_ci```ts
202e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci/* The credential data to be installed must be assigned by the service. The data in this example is not the real credential data. */
205e41f4b71Sopenharmony_cilet keystore: Uint8Array = new Uint8Array([
206e41f4b71Sopenharmony_ci  0x30, 0x82, 0x0b, 0xc1, 0x02, 0x01,
207e41f4b71Sopenharmony_ci]);
208e41f4b71Sopenharmony_cilet keystorePwd: string = "123456";
209e41f4b71Sopenharmony_citry {
210e41f4b71Sopenharmony_ci  certificateManager.installPrivateCertificate(keystore, keystorePwd, "test", (err, cmResult) => {
211e41f4b71Sopenharmony_ci    if (err != null) {
212e41f4b71Sopenharmony_ci      console.error(`Failed to install private certificate. Code: ${err.code}, message: ${err.message}`);
213e41f4b71Sopenharmony_ci    } else {
214e41f4b71Sopenharmony_ci      let uri: string = (cmResult?.uri == undefined) ? '' : cmResult.uri;
215e41f4b71Sopenharmony_ci      console.info('Succeeded in installing private certificate.');
216e41f4b71Sopenharmony_ci    }
217e41f4b71Sopenharmony_ci  });
218e41f4b71Sopenharmony_ci} catch (error) {
219e41f4b71Sopenharmony_ci  console.error(`Failed to install private certificate. Code: ${error.code}, message: ${error.message}`);
220e41f4b71Sopenharmony_ci}
221e41f4b71Sopenharmony_ci```
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci## certificateManager.installPrivateCertificate
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ciinstallPrivateCertificate(keystore: Uint8Array, keystorePwd: string, certAlias: string): Promise\<CMResult>
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ciInstalls a private credential. This API uses a promise to return the result.
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**Parameters**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
236e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
237e41f4b71Sopenharmony_ci| keystore | Uint8Array                   | Yes  | Keystore file containing the key pair and certificate.|
238e41f4b71Sopenharmony_ci| keystorePwd | string | Yes  | Password of the keystore file. The password cannot exceed 32 bytes.|
239e41f4b71Sopenharmony_ci| certAlias | string | Yes  | Credential alias. Currently, the alias can contain only digits, letters, and underscores (_) and should not exceed 32 bytes.|
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci**Return value**
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
244e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
245e41f4b71Sopenharmony_ci| Promise\<[CMResult](#cmresult)> | Promise used to return the operation result, that is, **uri** in the [CMResult](#cmresult) object.|
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci**Error codes**
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
252e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
253e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
254e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
255e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
256e41f4b71Sopenharmony_ci| 17500003 | The keystore is in an invalid format or the keystore password is incorrect. |
257e41f4b71Sopenharmony_ci| 17500004<sup>12+</sup> | The number of certificates or credentials reaches the maximum allowed. |
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci**Example**
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci```ts
262e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
263e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci/* The credential data to be installed must be assigned by the service. The data in this example is not the real credential data. */
266e41f4b71Sopenharmony_cilet keystore: Uint8Array = new Uint8Array([
267e41f4b71Sopenharmony_ci  0x30, 0x82, 0x0b, 0xc1, 0x02, 0x01,
268e41f4b71Sopenharmony_ci]);
269e41f4b71Sopenharmony_cilet keystorePwd: string = "123456";
270e41f4b71Sopenharmony_citry {
271e41f4b71Sopenharmony_ci  certificateManager.installPrivateCertificate(keystore, keystorePwd, 'test').then((cmResult) => {
272e41f4b71Sopenharmony_ci    let uri: string = (cmResult?.uri == undefined) ? '' : cmResult.uri;
273e41f4b71Sopenharmony_ci    console.info('Succeeded in installing private certificate.');
274e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
275e41f4b71Sopenharmony_ci    console.error(`Failed to install private certificate. Code: ${err.code}, message: ${err.message}`);
276e41f4b71Sopenharmony_ci  })
277e41f4b71Sopenharmony_ci} catch (error) {
278e41f4b71Sopenharmony_ci  console.error(`Failed to install private certificate. Code: ${error.code}, message: ${error.message}`);
279e41f4b71Sopenharmony_ci}
280e41f4b71Sopenharmony_ci```
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci## certificateManager.getPrivateCertificate
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_cigetPrivateCertificate(keyUri: string, callback: AsyncCallback\<CMResult>): void
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ciObtains detailed information about a private credential. This API uses an asynchronous callback to return the result.
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
291e41f4b71Sopenharmony_ci
292e41f4b71Sopenharmony_ci**Parameters**
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
295e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
296e41f4b71Sopenharmony_ci| keyUri | string                   | Yes  | Unique identifier of the target credential.|
297e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[CMResult](#cmresult)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is **credential** in the [CMResult](#cmresult) object. Otherwise, **err** is an error object.|
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**Error codes**
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci| ID| Error Message     |
304e41f4b71Sopenharmony_ci| -------- | ------------- |
305e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
306e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
307e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
308e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**Example**
311e41f4b71Sopenharmony_ci```ts
312e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_cilet uri: string = 'test'; /* URI of the credential installed. The process for installing the credential is omitted here. */
315e41f4b71Sopenharmony_citry {
316e41f4b71Sopenharmony_ci  certificateManager.getPrivateCertificate(uri, (err, cmResult) => {
317e41f4b71Sopenharmony_ci    if (err != null) {
318e41f4b71Sopenharmony_ci      console.error(`Failed to get private certificate. Code: ${err.code}, message: ${err.message}`);
319e41f4b71Sopenharmony_ci    } else {
320e41f4b71Sopenharmony_ci      if (cmResult?.credential == undefined) {
321e41f4b71Sopenharmony_ci        console.info('The result of getting private certificate is undefined.');
322e41f4b71Sopenharmony_ci      } else {
323e41f4b71Sopenharmony_ci        let list = cmResult.credential;
324e41f4b71Sopenharmony_ci        console.info('Succeeded in getting private certificate.');
325e41f4b71Sopenharmony_ci      }
326e41f4b71Sopenharmony_ci    }
327e41f4b71Sopenharmony_ci  });
328e41f4b71Sopenharmony_ci} catch (error) {
329e41f4b71Sopenharmony_ci  console.error(`Failed to get private certificate. Code: ${error.code}, message: ${error.message}`);
330e41f4b71Sopenharmony_ci}
331e41f4b71Sopenharmony_ci```
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci## certificateManager.getPrivateCertificate
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_cigetPrivateCertificate(keyUri: string): Promise\<CMResult>
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ciObtains detailed information about a private credential. This API uses a promise to return the result.
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci**Parameters**
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
346e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
347e41f4b71Sopenharmony_ci| keyUri | string                   | Yes  | Unique identifier of the target credential.|
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci**Return value**
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
352e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
353e41f4b71Sopenharmony_ci| Promise\<[CMResult](#cmresult)> | Promise used to return the private credential details obtained, that is, **credential** in the [CMResult](#cmresult) object.|
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci**Error codes**
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci| ID| Error Message     |
360e41f4b71Sopenharmony_ci| -------- | ------------- |
361e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
362e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
363e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
364e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**Example**
367e41f4b71Sopenharmony_ci```ts
368e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
369e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_cilet uri: string = 'test'; /* URI of the credential installed. The process for installing the credential is omitted here. */
372e41f4b71Sopenharmony_citry {
373e41f4b71Sopenharmony_ci  certificateManager.getPrivateCertificate(uri).then((cmResult) => {
374e41f4b71Sopenharmony_ci    if (cmResult?.credential == undefined) {
375e41f4b71Sopenharmony_ci      console.info('The result of getting private certificate is undefined.');
376e41f4b71Sopenharmony_ci    } else {
377e41f4b71Sopenharmony_ci      let list = cmResult.credential;
378e41f4b71Sopenharmony_ci      console.info('Succeeded in getting private certificate.');
379e41f4b71Sopenharmony_ci    }
380e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
381e41f4b71Sopenharmony_ci    console.error(`Failed to get private certificate. Code: ${err.code}, message: ${err.message}`);
382e41f4b71Sopenharmony_ci  })
383e41f4b71Sopenharmony_ci} catch (error) {
384e41f4b71Sopenharmony_ci  console.error(`Failed to get private certificate. Code: ${error.code}, message: ${error.message}`);
385e41f4b71Sopenharmony_ci}
386e41f4b71Sopenharmony_ci```
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci## certificateManager.uninstallPrivateCertificate
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ciuninstallPrivateCertificate(keyUri: string, callback: AsyncCallback\<void>): void
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ciUninstalls a private credential. This API uses an asynchronous callback to return the result.
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ci**Parameters**
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
401e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
402e41f4b71Sopenharmony_ci| keyUri | string                   | Yes  | Unique identifier of the credential to uninstall.|
403e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci**Error codes**
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci| ID| Error Message     |
410e41f4b71Sopenharmony_ci| -------- | ------------- |
411e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
412e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
413e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
414e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ci**Example**
417e41f4b71Sopenharmony_ci```ts
418e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_cilet uri: string = 'test'; /* URI of the credential installed. The process for installing the credential is omitted here. */
421e41f4b71Sopenharmony_citry {
422e41f4b71Sopenharmony_ci  certificateManager.uninstallPrivateCertificate(uri, (err, result) => {
423e41f4b71Sopenharmony_ci    if (err != null) {
424e41f4b71Sopenharmony_ci      console.error(`Failed to uninstall private certificate. Code: ${err.code}, message: ${err.message}`);
425e41f4b71Sopenharmony_ci    } else {
426e41f4b71Sopenharmony_ci      console.info('Succeeded in uninstalling private certificate.');
427e41f4b71Sopenharmony_ci    }
428e41f4b71Sopenharmony_ci  });
429e41f4b71Sopenharmony_ci} catch (error) {
430e41f4b71Sopenharmony_ci  console.error(`Failed to uninstall private certificate. Code: ${error.code}, message: ${error.message}`);
431e41f4b71Sopenharmony_ci}
432e41f4b71Sopenharmony_ci```
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci## certificateManager.uninstallPrivateCertificate
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ciuninstallPrivateCertificate(keyUri: string): Promise\<void>
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ciUninstalls a private credential. This API uses a promise to return the result.
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci**Parameters**
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
447e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
448e41f4b71Sopenharmony_ci| keyUri | string                   | Yes  | Unique identifier of the credential to uninstall.|
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci**Return value**
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci| Type                                       | Description                |
453e41f4b71Sopenharmony_ci| ------------------------------------------- | -------------------- |
454e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**Error codes**
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci| ID| Error Message     |
461e41f4b71Sopenharmony_ci| -------- | ------------- |
462e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
463e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
464e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
465e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
466e41f4b71Sopenharmony_ci
467e41f4b71Sopenharmony_ci**Example**
468e41f4b71Sopenharmony_ci```ts
469e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
470e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_cilet uri: string = 'test'; /* URI of the credential installed. The process for installing the credential is omitted here. */
473e41f4b71Sopenharmony_citry {
474e41f4b71Sopenharmony_ci  certificateManager.uninstallPrivateCertificate(uri).then((cmResult) => {
475e41f4b71Sopenharmony_ci    console.info('Succeeded in uninstalling private certificate.');
476e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
477e41f4b71Sopenharmony_ci    console.error(`Failed to uninstall private certificate. Code: ${err.code}, message: ${err.message}`);
478e41f4b71Sopenharmony_ci  })
479e41f4b71Sopenharmony_ci} catch (error) {
480e41f4b71Sopenharmony_ci  console.error(`Failed to uninstall private certificate. Code: ${error.code}, message: ${error.message}`);
481e41f4b71Sopenharmony_ci}
482e41f4b71Sopenharmony_ci```
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci## certificateManager.init
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ciinit(authUri: string, spec: CMSignatureSpec, callback: AsyncCallback\<CMHandle>): void
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ciInitializes the signing or signature verification operation using the specified credential. This API uses an asynchronous callback to return the result.
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci**Parameters**
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
497e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
498e41f4b71Sopenharmony_ci| authUri | string                   | Yes  | Unique identifier of the credential to use.|
499e41f4b71Sopenharmony_ci| spec | [CMSignatureSpec](#cmsignaturespec) | Yes  | Parameters for the signing or signature verification operation.|
500e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[CMHandle](#cmhandle)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the obtained **CMHandle**. Otherwise, **err** is an error object.|
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci**Error codes**
503e41f4b71Sopenharmony_ci
504e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci| ID| Error Message     |
507e41f4b71Sopenharmony_ci| -------- | ------------- |
508e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
509e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
510e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
511e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
512e41f4b71Sopenharmony_ci| 17500005<sup>12+</sup> | The application is not authorized by the user. |
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci**Example**
515e41f4b71Sopenharmony_ci```ts
516e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_cilet uri: string = 'test'; /* URI of the credential installed. The process for installing the credential is omitted here. */
519e41f4b71Sopenharmony_ciconst req: certificateManager.CMSignatureSpec = {
520e41f4b71Sopenharmony_ci  purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_SIGN,
521e41f4b71Sopenharmony_ci  padding: certificateManager.CmKeyPadding.CM_PADDING_PSS,
522e41f4b71Sopenharmony_ci  digest: certificateManager.CmKeyDigest.CM_DIGEST_SHA256
523e41f4b71Sopenharmony_ci}
524e41f4b71Sopenharmony_citry {
525e41f4b71Sopenharmony_ci  certificateManager.init(uri, req, (err, cmHandle) => {
526e41f4b71Sopenharmony_ci    if (err != null) {
527e41f4b71Sopenharmony_ci      console.error(`Failed to init. Code: ${err.code}, message: ${err.message}`);
528e41f4b71Sopenharmony_ci    } else {
529e41f4b71Sopenharmony_ci      console.info('Succeeded in initiating.');
530e41f4b71Sopenharmony_ci    }
531e41f4b71Sopenharmony_ci  })
532e41f4b71Sopenharmony_ci} catch (error) {
533e41f4b71Sopenharmony_ci  console.error(`Failed to init. Code: ${error.code}, message: ${error.message}`);
534e41f4b71Sopenharmony_ci}
535e41f4b71Sopenharmony_ci```
536e41f4b71Sopenharmony_ci
537e41f4b71Sopenharmony_ci## certificateManager.init
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ciinit(authUri: string, spec: CMSignatureSpec): Promise\<CMHandle>
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ciInitializes the signing or signature verification operation using the specified credential. This API uses a promise to return the result.
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ci**Parameters**
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
550e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
551e41f4b71Sopenharmony_ci| authUri | string                   | Yes  | Unique identifier of the credential to use.|
552e41f4b71Sopenharmony_ci| spec | [CMSignatureSpec](#cmsignaturespec) | Yes  | Parameters for the signing or signature verification operation.|
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci**Return value**
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ci| Type                                       | Description                |
557e41f4b71Sopenharmony_ci| ------------------------------------------- | -------------------- |
558e41f4b71Sopenharmony_ci| Promise\<[CMHandle](#cmhandle)> | Promise used to return an operation handle.|
559e41f4b71Sopenharmony_ci
560e41f4b71Sopenharmony_ci**Error codes**
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci| ID| Error Message     |
565e41f4b71Sopenharmony_ci| -------- | ------------- |
566e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
567e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
568e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
569e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
570e41f4b71Sopenharmony_ci| 17500005<sup>12+</sup> | The application is not authorized by the user. |
571e41f4b71Sopenharmony_ci
572e41f4b71Sopenharmony_ci**Example**
573e41f4b71Sopenharmony_ci```ts
574e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
575e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_cilet uri: string = 'test'; /* URI of the credential installed. The process for installing the credential is omitted here. */
578e41f4b71Sopenharmony_ciconst req: certificateManager.CMSignatureSpec = {
579e41f4b71Sopenharmony_ci  purpose: certificateManager.CmKeyPurpose.CM_KEY_PURPOSE_VERIFY,
580e41f4b71Sopenharmony_ci  padding: certificateManager.CmKeyPadding.CM_PADDING_PSS,
581e41f4b71Sopenharmony_ci  digest: certificateManager.CmKeyDigest.CM_DIGEST_MD5
582e41f4b71Sopenharmony_ci}
583e41f4b71Sopenharmony_citry {
584e41f4b71Sopenharmony_ci  certificateManager.init(uri, req).then((handle) => {
585e41f4b71Sopenharmony_ci    console.info('Succeeded in initiating.');
586e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
587e41f4b71Sopenharmony_ci    console.error(`Failed to init. Code: ${err.code}, message: ${err.message}`);
588e41f4b71Sopenharmony_ci  })
589e41f4b71Sopenharmony_ci} catch (error) {
590e41f4b71Sopenharmony_ci  console.error(`Failed to init. Code: ${error.code}, message: ${error.message}`);
591e41f4b71Sopenharmony_ci}
592e41f4b71Sopenharmony_ci```
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_ci## certificateManager.update
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ciupdate(handle: Uint8Array, data: Uint8Array, callback: AsyncCallback\<void>): void
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ciUpdates the data for the signing or signature verification operation. This API uses an asynchronous callback to return the result.
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
603e41f4b71Sopenharmony_ci
604e41f4b71Sopenharmony_ci**Parameters**
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
607e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
608e41f4b71Sopenharmony_ci| handle | Uint8Array                   | Yes  | Operation handle returned by **init()**.|
609e41f4b71Sopenharmony_ci| data | Uint8Array                   | Yes  | Data to be signed or verified.|
610e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci**Error codes**
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
617e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
618e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
619e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
620e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci**Example**
623e41f4b71Sopenharmony_ci```ts
624e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ci/* cmHandle is the value returned by init(). The value here is only an example. */
627e41f4b71Sopenharmony_cilet cmHandle: Uint8Array = new Uint8Array([
628e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
629e41f4b71Sopenharmony_ci]);
630e41f4b71Sopenharmony_cilet srcData: Uint8Array = new Uint8Array([
631e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
632e41f4b71Sopenharmony_ci]);
633e41f4b71Sopenharmony_citry {
634e41f4b71Sopenharmony_ci  certificateManager.update(cmHandle, srcData, (err, result) => {
635e41f4b71Sopenharmony_ci    if (err != null) {
636e41f4b71Sopenharmony_ci      console.error(`Failed to update. Code: ${err.code}, message: ${err.message}`);
637e41f4b71Sopenharmony_ci    } else {
638e41f4b71Sopenharmony_ci      console.info('Succeeded in updating.');
639e41f4b71Sopenharmony_ci    }
640e41f4b71Sopenharmony_ci  });
641e41f4b71Sopenharmony_ci} catch (error) {
642e41f4b71Sopenharmony_ci  console.error(`Failed to update. Code: ${error.code}, message: ${error.message}`);
643e41f4b71Sopenharmony_ci}
644e41f4b71Sopenharmony_ci```
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci## certificateManager.update
647e41f4b71Sopenharmony_ci
648e41f4b71Sopenharmony_ciupdate(handle: Uint8Array, data: Uint8Array): Promise\<void>
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ciUpdates the data for the signing or signature verification operation. This API uses a promise to return the result.
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci**Parameters**
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
659e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
660e41f4b71Sopenharmony_ci| handle | Uint8Array                   | Yes  | Operation handle returned by **init()**.|
661e41f4b71Sopenharmony_ci| data | Uint8Array                   | Yes  | Data to be signed or verified.|
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci**Return value**
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci| Type                                       | Description                |
666e41f4b71Sopenharmony_ci| ------------------------------------------- | -------------------- |
667e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci**Error codes**
670e41f4b71Sopenharmony_ci
671e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
674e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
675e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
676e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
677e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci**Example**
680e41f4b71Sopenharmony_ci```ts
681e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
682e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
683e41f4b71Sopenharmony_ci
684e41f4b71Sopenharmony_ci/* cmHandle is the value returned by init(). The value here is only an example. */
685e41f4b71Sopenharmony_cilet cmHandle: Uint8Array = new Uint8Array([
686e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
687e41f4b71Sopenharmony_ci]);
688e41f4b71Sopenharmony_cilet srcData: Uint8Array = new Uint8Array([
689e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
690e41f4b71Sopenharmony_ci]);
691e41f4b71Sopenharmony_citry {
692e41f4b71Sopenharmony_ci  certificateManager.update(cmHandle, srcData).then((result) => {
693e41f4b71Sopenharmony_ci    console.info('Succeeded in updating.');
694e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
695e41f4b71Sopenharmony_ci    console.error(`Failed to update. Code: ${err.code}, message: ${err.message}`);
696e41f4b71Sopenharmony_ci  })
697e41f4b71Sopenharmony_ci} catch (error) {
698e41f4b71Sopenharmony_ci  console.error(`Failed to update. Code: ${error.code}, message: ${error.message}`);
699e41f4b71Sopenharmony_ci}
700e41f4b71Sopenharmony_ci```
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_ci## certificateManager.finish
703e41f4b71Sopenharmony_ci
704e41f4b71Sopenharmony_cifinish(handle: Uint8Array, callback: AsyncCallback\<CMResult>): void
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_ciFinishes the signing operation. This API uses an asynchronous callback to return the result.
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**Parameters**
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
715e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
716e41f4b71Sopenharmony_ci| handle | Uint8Array                   | Yes  | Operation handle returned by **init()**.|
717e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[CMResult](#cmresult)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the signature, that is, **outData** of the [CMResult](#cmresult) object. Otherwise, **err** is an error object.|
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci**Error codes**
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
724e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
725e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
726e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
727e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ci**Example**
730e41f4b71Sopenharmony_ci```ts
731e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci/* cmHandle is the value returned by init(). The value here is only an example. */
734e41f4b71Sopenharmony_cilet cmHandle: Uint8Array = new Uint8Array([
735e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
736e41f4b71Sopenharmony_ci]);
737e41f4b71Sopenharmony_citry {
738e41f4b71Sopenharmony_ci  certificateManager.finish(cmHandle, (err, cmResult) => {
739e41f4b71Sopenharmony_ci    if (err != null) {
740e41f4b71Sopenharmony_ci      console.error(`Failed to finish. Code: ${err.code}, message: ${err.message}`);
741e41f4b71Sopenharmony_ci    } else {
742e41f4b71Sopenharmony_ci      if (cmResult?.outData != undefined) {
743e41f4b71Sopenharmony_ci        let signRes: Uint8Array = cmResult.outData;
744e41f4b71Sopenharmony_ci        console.info('Succeeded in finishing.');
745e41f4b71Sopenharmony_ci      } else {
746e41f4b71Sopenharmony_ci        console.info('The result of finishing is undefined.');
747e41f4b71Sopenharmony_ci      }
748e41f4b71Sopenharmony_ci    }
749e41f4b71Sopenharmony_ci  });
750e41f4b71Sopenharmony_ci} catch(error) {
751e41f4b71Sopenharmony_ci  console.error(`Failed to finish. Code: ${error.code}, message: ${error.message}`);
752e41f4b71Sopenharmony_ci}
753e41f4b71Sopenharmony_ci```
754e41f4b71Sopenharmony_ci
755e41f4b71Sopenharmony_ci## certificateManager.finish
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_cifinish(handle: Uint8Array, signature: Uint8Array, callback: AsyncCallback\<CMResult>): void
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ciFinishes the signature verification operation. This API uses an asynchronous callback to return the result.
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci**Parameters**
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
768e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
769e41f4b71Sopenharmony_ci| handle | Uint8Array                   | Yes  | Operation handle returned by **init()**.|
770e41f4b71Sopenharmony_ci| signature | Uint8Array                   | Yes  | Signature data to verify.|
771e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[CMResult](#cmresult)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci**Error codes**
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
778e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
779e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
780e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
781e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci**Example**
784e41f4b71Sopenharmony_ci```ts
785e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci/* cmHandle is the value returned by init(). The value here is only an example. */
788e41f4b71Sopenharmony_cilet cmHandle: Uint8Array = new Uint8Array([
789e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
790e41f4b71Sopenharmony_ci]);
791e41f4b71Sopenharmony_cilet signRes: Uint8Array = new Uint8Array([
792e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
793e41f4b71Sopenharmony_ci]);
794e41f4b71Sopenharmony_citry {
795e41f4b71Sopenharmony_ci  certificateManager.finish(cmHandle, signRes, (err, cmResult) => {
796e41f4b71Sopenharmony_ci    if (err != null) {
797e41f4b71Sopenharmony_ci      console.error(`Failed to finish. Code: ${err.code}, message: ${err.message}`);
798e41f4b71Sopenharmony_ci    } else {
799e41f4b71Sopenharmony_ci      console.info('Succeeded in finishing.');
800e41f4b71Sopenharmony_ci    }
801e41f4b71Sopenharmony_ci  });
802e41f4b71Sopenharmony_ci} catch(error) {
803e41f4b71Sopenharmony_ci  console.error(`Failed to finish. Code: ${error.code}, message: ${error.message}`);
804e41f4b71Sopenharmony_ci}
805e41f4b71Sopenharmony_ci```
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_ci## certificateManager.finish
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_cifinish(handle: Uint8Array, signature?: Uint8Array): Promise\<CMResult>
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ciFinishes the signing or signature verification operation. This API uses a promise to return the result.
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
814e41f4b71Sopenharmony_ci
815e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci**Parameters**
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
820e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
821e41f4b71Sopenharmony_ci| handle | Uint8Array                   | Yes  | Operation handle returned by **init()**.|
822e41f4b71Sopenharmony_ci| signature | Uint8Array                   | No  | Data to sign or verify.|
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci**Return value**
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
827e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
828e41f4b71Sopenharmony_ci| Promise\<[CMResult](#cmresult)> | Promise used to return the result. For a signing operation, the promise returns the signature, that is, **outData** in the [CMResult](#cmresult) object, is returned. For a signature verification operation, the promise returns no value.|
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci**Error codes**
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
835e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
836e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
837e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
838e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ci**Example**
841e41f4b71Sopenharmony_ci```ts
842e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
843e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
844e41f4b71Sopenharmony_ci
845e41f4b71Sopenharmony_ci/* cmHandle is the value returned by init(). The value here is only an example. */
846e41f4b71Sopenharmony_cilet cmHandle: Uint8Array = new Uint8Array([
847e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
848e41f4b71Sopenharmony_ci]);
849e41f4b71Sopenharmony_citry {
850e41f4b71Sopenharmony_ci  /* Finish the signing operation. */
851e41f4b71Sopenharmony_ci  certificateManager.finish(cmHandle).then((cmResult) => {
852e41f4b71Sopenharmony_ci    if (cmResult?.outData != undefined) {
853e41f4b71Sopenharmony_ci      let signRes1: Uint8Array = cmResult.outData;
854e41f4b71Sopenharmony_ci      console.info('Succeeded in finishing signature.');
855e41f4b71Sopenharmony_ci    } else {
856e41f4b71Sopenharmony_ci      console.info('The result of signature is undefined.');
857e41f4b71Sopenharmony_ci    }
858e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
859e41f4b71Sopenharmony_ci    console.error(`Failed to finish signature. Code: ${err.code}, message: ${err.message}`);
860e41f4b71Sopenharmony_ci  })
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci  /* Signature generated. */
863e41f4b71Sopenharmony_ci  let signRes: Uint8Array = new Uint8Array([
864e41f4b71Sopenharmony_ci    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
865e41f4b71Sopenharmony_ci  ]);
866e41f4b71Sopenharmony_ci  /* Finish the signature verification operation. */
867e41f4b71Sopenharmony_ci  certificateManager.finish(cmHandle, signRes).then((cmResult) => {
868e41f4b71Sopenharmony_ci    console.info('Succeeded in finishing verification.');
869e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
870e41f4b71Sopenharmony_ci    console.error(`Failed to finish verification. Code: ${err.code}, message: ${err.message}`);
871e41f4b71Sopenharmony_ci  })
872e41f4b71Sopenharmony_ci} catch(error) {
873e41f4b71Sopenharmony_ci  console.error(`Failed to finish. Code: ${error.code}, message: ${error.message}`);
874e41f4b71Sopenharmony_ci}
875e41f4b71Sopenharmony_ci```
876e41f4b71Sopenharmony_ci
877e41f4b71Sopenharmony_ci## certificateManager.abort
878e41f4b71Sopenharmony_ci
879e41f4b71Sopenharmony_ciabort(handle: Uint8Array, callback: AsyncCallback\<void>): void
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_ciAborts the signing or signature verification operation. This API uses an asynchronous callback to return the result.
882e41f4b71Sopenharmony_ci
883e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
884e41f4b71Sopenharmony_ci
885e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
886e41f4b71Sopenharmony_ci
887e41f4b71Sopenharmony_ci**Parameters**
888e41f4b71Sopenharmony_ci
889e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
890e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
891e41f4b71Sopenharmony_ci| handle | Uint8Array                   | Yes  | Operation handle returned by **init()**.|
892e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ci**Error codes**
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
899e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
900e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
901e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
902e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
903e41f4b71Sopenharmony_ci
904e41f4b71Sopenharmony_ci**Example**
905e41f4b71Sopenharmony_ci```ts
906e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
907e41f4b71Sopenharmony_ci
908e41f4b71Sopenharmony_ci/* cmHandle is the value returned by init(). The value here is only an example. */
909e41f4b71Sopenharmony_cilet cmHandle: Uint8Array = new Uint8Array([
910e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
911e41f4b71Sopenharmony_ci]);
912e41f4b71Sopenharmony_citry {
913e41f4b71Sopenharmony_ci  certificateManager.abort(cmHandle, (err, cmResult) => {
914e41f4b71Sopenharmony_ci    if (err != null) {
915e41f4b71Sopenharmony_ci      console.error(`Failed to abort. Code: ${err.code}, message: ${err.message}`);
916e41f4b71Sopenharmony_ci    } else {
917e41f4b71Sopenharmony_ci      console.info('Succeeded in aborting.');
918e41f4b71Sopenharmony_ci    }
919e41f4b71Sopenharmony_ci  });
920e41f4b71Sopenharmony_ci} catch(error) {
921e41f4b71Sopenharmony_ci  console.error(`Failed to abort. Code: ${error.code}, message: ${error.message}`);
922e41f4b71Sopenharmony_ci}
923e41f4b71Sopenharmony_ci```
924e41f4b71Sopenharmony_ci
925e41f4b71Sopenharmony_ci## certificateManager.abort
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ciabort(handle: Uint8Array): Promise\<void>
928e41f4b71Sopenharmony_ci
929e41f4b71Sopenharmony_ciAborts the signing or signature verification operation. This API uses a promise to return the result.
930e41f4b71Sopenharmony_ci
931e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
932e41f4b71Sopenharmony_ci
933e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
934e41f4b71Sopenharmony_ci
935e41f4b71Sopenharmony_ci**Parameters**
936e41f4b71Sopenharmony_ci
937e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
938e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
939e41f4b71Sopenharmony_ci| handle | Uint8Array                   | Yes  | Operation handle returned by **init()**.|
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci**Return value**
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_ci| Type                                       | Description                |
944e41f4b71Sopenharmony_ci| ------------------------------------------- | -------------------- |
945e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.|
946e41f4b71Sopenharmony_ci
947e41f4b71Sopenharmony_ci**Error codes**
948e41f4b71Sopenharmony_ci
949e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_ci| ID| Error Message                                                    |
952e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
953e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API.     |
954e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
955e41f4b71Sopenharmony_ci| 17500001 | Internal error.     |
956e41f4b71Sopenharmony_ci
957e41f4b71Sopenharmony_ci**Example**
958e41f4b71Sopenharmony_ci```ts
959e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
960e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_ci/* cmHandle is the value returned by init(). The value here is only an example. */
963e41f4b71Sopenharmony_cilet cmHandle: Uint8Array = new Uint8Array([
964e41f4b71Sopenharmony_ci  0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
965e41f4b71Sopenharmony_ci]);
966e41f4b71Sopenharmony_citry {
967e41f4b71Sopenharmony_ci  certificateManager.abort(cmHandle).then((result) => {
968e41f4b71Sopenharmony_ci    console.info('Succeeded in aborting.');
969e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
970e41f4b71Sopenharmony_ci    console.error(`Failed to abort. Code: ${err.code}, message: ${err.message}`);
971e41f4b71Sopenharmony_ci  })
972e41f4b71Sopenharmony_ci} catch (error) {
973e41f4b71Sopenharmony_ci  console.error(`Failed to abort. Code: ${error.code}, message: ${error.message}`);
974e41f4b71Sopenharmony_ci}
975e41f4b71Sopenharmony_ci```
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_ci## certificateManager.getPublicCertificate<sup>12+</sup>
978e41f4b71Sopenharmony_ci
979e41f4b71Sopenharmony_cigetPublicCertificate(keyUri: string): Promise\<CMResult>
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_ciObtains detailed information about a public credential. This API uses a promise to return the result.
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_ci**Parameters**
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
990e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
991e41f4b71Sopenharmony_ci| keyUri | string                   | Yes  | Unique identifier of the public credential.|
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci**Return value**
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
996e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
997e41f4b71Sopenharmony_ci| Promise\<[CMResult](#cmresult)> | Promise used to return the detailed information about the user's public credential obtained, that is, **credential** in the [CMResult](#cmresult) object.|
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci**Error codes**
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci| ID| Error Message     |
1004e41f4b71Sopenharmony_ci| -------- | ------------- |
1005e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. |
1006e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1007e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
1008e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
1009e41f4b71Sopenharmony_ci| 17500005 | The application is not authorized by the user. |
1010e41f4b71Sopenharmony_ci
1011e41f4b71Sopenharmony_ci**Example**
1012e41f4b71Sopenharmony_ci```ts
1013e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
1014e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1015e41f4b71Sopenharmony_ci
1016e41f4b71Sopenharmony_cilet uri: string = 'test'; /* Unique identifier of the public credential. The process for installing the public credential is omitted here. */
1017e41f4b71Sopenharmony_citry {
1018e41f4b71Sopenharmony_ci  certificateManager.getPublicCertificate(uri).then((cmResult) => {
1019e41f4b71Sopenharmony_ci    if (cmResult?.credential == undefined) {
1020e41f4b71Sopenharmony_ci      console.info('The result of getting public certificate is undefined.');
1021e41f4b71Sopenharmony_ci    } else {
1022e41f4b71Sopenharmony_ci      let cred = cmResult.credential;
1023e41f4b71Sopenharmony_ci      console.info('Succeeded in getting Public certificate.');
1024e41f4b71Sopenharmony_ci    }
1025e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1026e41f4b71Sopenharmony_ci    console.error(`Failed to get Public certificate. Code: ${err.code}, message: ${err.message}`);
1027e41f4b71Sopenharmony_ci  })
1028e41f4b71Sopenharmony_ci} catch (error) {
1029e41f4b71Sopenharmony_ci  console.error(`Failed to get Public certificate. Code: ${error.code}, message: ${error.message}`);
1030e41f4b71Sopenharmony_ci}
1031e41f4b71Sopenharmony_ci```
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ci## certificateManager.isAuthorizedApp<sup>12+</sup>
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_ciisAuthorizedApp(keyUri: string): Promise\<boolean>
1036e41f4b71Sopenharmony_ci
1037e41f4b71Sopenharmony_ciChecks whether this application is authorized by the specified user credential. This API uses a promise to return the result.
1038e41f4b71Sopenharmony_ci
1039e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
1042e41f4b71Sopenharmony_ci
1043e41f4b71Sopenharmony_ci**Parameters**
1044e41f4b71Sopenharmony_ci
1045e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
1046e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
1047e41f4b71Sopenharmony_ci| keyUri | string                   | Yes  | Unique identifier of the credential.|
1048e41f4b71Sopenharmony_ci
1049e41f4b71Sopenharmony_ci**Return value**
1050e41f4b71Sopenharmony_ci
1051e41f4b71Sopenharmony_ci| Type             | Description                                                        |
1052e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------------------------ |
1053e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise used to return a Boolean value, which indicates whether the application is authorized by the specified user credential.|
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ci**Error codes**
1056e41f4b71Sopenharmony_ci
1057e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
1058e41f4b71Sopenharmony_ci
1059e41f4b71Sopenharmony_ci| ID| Error Message     |
1060e41f4b71Sopenharmony_ci| -------- | ------------- |
1061e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. |
1062e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1063e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
1064e41f4b71Sopenharmony_ci
1065e41f4b71Sopenharmony_ci**Example**
1066e41f4b71Sopenharmony_ci```ts
1067e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
1068e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_cilet uri: string = 'test'; /* Unique identifier of the credential. The process for authorizing the credential to the application is omitted here. */
1071e41f4b71Sopenharmony_citry {
1072e41f4b71Sopenharmony_ci  certificateManager.isAuthorizedApp(uri).then((res) => {
1073e41f4b71Sopenharmony_ci    if (res) {
1074e41f4b71Sopenharmony_ci      console.info('The application is authorized by the user.');
1075e41f4b71Sopenharmony_ci    } else {
1076e41f4b71Sopenharmony_ci      console.info('The application is not authorized by the user.');
1077e41f4b71Sopenharmony_ci    }
1078e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1079e41f4b71Sopenharmony_ci    console.error(`Failed to get Public certificate. Code: ${err.code}, message: ${err.message}`);
1080e41f4b71Sopenharmony_ci  })
1081e41f4b71Sopenharmony_ci} catch (error) {
1082e41f4b71Sopenharmony_ci  console.error(`Failed to get Public certificate. Code: ${error.code}, message: ${error.message}`);
1083e41f4b71Sopenharmony_ci}
1084e41f4b71Sopenharmony_ci```
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci## certificateManager.getAllUserTrustedCertificates<sup>12+</sup>
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_cigetAllUserTrustedCertificates(): Promise\<CMResult>
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ciObtains all the user root CA certificates. The API uses a promise to return the result.
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_ci**Return value**
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
1099e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
1100e41f4b71Sopenharmony_ci| Promise\<[CMResult](#cmresult)> | Promise used to return the user's root CA certificates obtained, that is, **certList** in the [CMResult](#cmresult) object.|
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ci**Error codes**
1103e41f4b71Sopenharmony_ci
1104e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci| ID| Error Message     |
1107e41f4b71Sopenharmony_ci| -------- | ------------- |
1108e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. |
1109e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ci**Example**
1112e41f4b71Sopenharmony_ci```ts
1113e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
1114e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1115e41f4b71Sopenharmony_ci
1116e41f4b71Sopenharmony_citry {
1117e41f4b71Sopenharmony_ci  certificateManager.getAllUserTrustedCertificates().then((cmResult) => {
1118e41f4b71Sopenharmony_ci    if (cmResult?.certList == undefined) {
1119e41f4b71Sopenharmony_ci      console.info('The result of getting all user trusted certificates is undefined.');
1120e41f4b71Sopenharmony_ci    } else {
1121e41f4b71Sopenharmony_ci      let list = cmResult.certList;
1122e41f4b71Sopenharmony_ci      console.info('Succeeded in getting all user trusted certificates.');
1123e41f4b71Sopenharmony_ci    }
1124e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1125e41f4b71Sopenharmony_ci    console.error(`Failed to get all user trusted certificates. Code: ${err.code}, message: ${err.message}`);
1126e41f4b71Sopenharmony_ci  })
1127e41f4b71Sopenharmony_ci} catch (error) {
1128e41f4b71Sopenharmony_ci  console.error(`Failed to get all user trusted certificates. Code: ${error.code}, message: ${error.message}`);
1129e41f4b71Sopenharmony_ci}
1130e41f4b71Sopenharmony_ci```
1131e41f4b71Sopenharmony_ci
1132e41f4b71Sopenharmony_ci## certificateManager.getUserTrustedCertificate<sup>12+</sup>
1133e41f4b71Sopenharmony_ci
1134e41f4b71Sopenharmony_cigetUserTrustedCertificate(certUri: string): Promise\<CMResult>
1135e41f4b71Sopenharmony_ci
1136e41f4b71Sopenharmony_ciObtains the detailed information about a user root CA certificate. This API uses a promise to return the result.
1137e41f4b71Sopenharmony_ci
1138e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
1141e41f4b71Sopenharmony_ci
1142e41f4b71Sopenharmony_ci**Parameters**
1143e41f4b71Sopenharmony_ci
1144e41f4b71Sopenharmony_ci| Name  | Type                                             | Mandatory| Description                      |
1145e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | -------------------------- |
1146e41f4b71Sopenharmony_ci| certUri | string                   | Yes  | Unique identifier of the user root CA certificate.|
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci**Return value**
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
1151e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
1152e41f4b71Sopenharmony_ci| Promise\<[CMResult](#cmresult)> | Promise used to return the detailed CA certificate information obtained, that is, **certInfo** in the [CMResult](#cmresult) object.|
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci**Error codes**
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci| ID| Error Message     |
1159e41f4b71Sopenharmony_ci| -------- | ------------- |
1160e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. |
1161e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1162e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
1163e41f4b71Sopenharmony_ci| 17500002 | The certificate does not exist. |
1164e41f4b71Sopenharmony_ci
1165e41f4b71Sopenharmony_ci**Example**
1166e41f4b71Sopenharmony_ci```ts
1167e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
1168e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1169e41f4b71Sopenharmony_ci
1170e41f4b71Sopenharmony_cilet certUri: string = 'testUserCert'; /* Unique identifier of the user root CA certificate. The process of installing the user root CA certificate is omitted here. */
1171e41f4b71Sopenharmony_citry {
1172e41f4b71Sopenharmony_ci  certificateManager.getUserTrustedCertificate(certUri).then((cmResult) => {
1173e41f4b71Sopenharmony_ci    if (cmResult?.certInfo == undefined) {
1174e41f4b71Sopenharmony_ci      console.info('The result of getting user trusted certificate is undefined.');
1175e41f4b71Sopenharmony_ci    } else {
1176e41f4b71Sopenharmony_ci      let cert = cmResult.certInfo;
1177e41f4b71Sopenharmony_ci      console.info('Succeeded in getting user trusted certificate.');
1178e41f4b71Sopenharmony_ci    }
1179e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1180e41f4b71Sopenharmony_ci    console.error(`Failed to get user trusted certificate. Code: ${err.code}, message: ${err.message}`);
1181e41f4b71Sopenharmony_ci  })
1182e41f4b71Sopenharmony_ci} catch (error) {
1183e41f4b71Sopenharmony_ci  console.error(`Failed to get user trusted certificate. Code: ${error.code}, message: ${error.message}`);
1184e41f4b71Sopenharmony_ci}
1185e41f4b71Sopenharmony_ci```
1186e41f4b71Sopenharmony_ci## certificateManager.getPrivateCertificates<sup>13+</sup>
1187e41f4b71Sopenharmony_ci
1188e41f4b71Sopenharmony_cigetPrivateCertificates(): Promise\<CMResult>
1189e41f4b71Sopenharmony_ci
1190e41f4b71Sopenharmony_ciObtains the credentials for installing the application. This API uses a promise to return the result asynchronously.
1191e41f4b71Sopenharmony_ci
1192e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER
1193e41f4b71Sopenharmony_ci
1194e41f4b71Sopenharmony_ci**System capability**: System SystemCapability.Security.CertificateManager
1195e41f4b71Sopenharmony_ci
1196e41f4b71Sopenharmony_ci**Return value**
1197e41f4b71Sopenharmony_ci
1198e41f4b71Sopenharmony_ci| Type                           | Description                                                        |
1199e41f4b71Sopenharmony_ci| ------------------------------- | ------------------------------------------------------------ |
1200e41f4b71Sopenharmony_ci| Promise\<[CMResult](#cmresult)> | Promise used to return the credentials obtained, which is **credentialList** in [CMResult](#cmresult).|
1201e41f4b71Sopenharmony_ci
1202e41f4b71Sopenharmony_ci**Error codes**
1203e41f4b71Sopenharmony_ci
1204e41f4b71Sopenharmony_ciFor details about the following error codes, see [Certificate Management Error Codes](errorcode-certManager.md).
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ci| ID| Error Message     |
1207e41f4b71Sopenharmony_ci| -------- | ------------- |
1208e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. |
1209e41f4b71Sopenharmony_ci| 17500001 | Internal error. |
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_ci**Example**
1212e41f4b71Sopenharmony_ci```ts
1213e41f4b71Sopenharmony_ciimport { certificateManager } from '@kit.DeviceCertificateKit';
1214e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1215e41f4b71Sopenharmony_ci
1216e41f4b71Sopenharmony_citry {
1217e41f4b71Sopenharmony_ci  certificateManager.getPrivateCertificates().then((cmResult) => {
1218e41f4b71Sopenharmony_ci    if (cmResult?.credentialList == undefined) {
1219e41f4b71Sopenharmony_ci      console.info('The result of getting all private certificates installed by the application is undefined.');
1220e41f4b71Sopenharmony_ci    } else {
1221e41f4b71Sopenharmony_ci      let list = cmResult.credentialList;
1222e41f4b71Sopenharmony_ci      console.info('Succeeded in getting all private certificates installed by the application.');
1223e41f4b71Sopenharmony_ci    }
1224e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1225e41f4b71Sopenharmony_ci    console.error(`Failed to get all private certificates installed by the application. Code: ${err.code}, message: ${err.message}`);
1226e41f4b71Sopenharmony_ci  })
1227e41f4b71Sopenharmony_ci} catch (error) {
1228e41f4b71Sopenharmony_ci  console.error(`Failed to get all private certificates installed by the application. Code: ${error.code}, message: ${error.message}`);
1229e41f4b71Sopenharmony_ci}
1230e41f4b71Sopenharmony_ci```
1231