1# @ohos.security.certManagerDialog (Certificate Management Dialog Box) 2 3The **certificateManagerDialog** module provides APIs for opening the certificate management pages, on which the certificates are installed, stored, used, and destroyed. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 13. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```ts 12import certificateManagerDialog from '@ohos.security.certManagerDialog'; 13``` 14 15## CertificateDialogPageType 16 17Enumerates the page types of the certificate management dialog box. 18 19**System capability**: SystemCapability.Security.CertificateManagerDialog 20 21**Model restriction**: This API can be used only in the stage model. 22 23| Name | Value | Description | 24| ---------- | ------ | --------- | 25| PAGE_MAIN | 1 | Main page of the Certificate Manager application. | 26| PAGE_CA_CERTIFICATE | 2 | CA certificate list page. | 27| PAGE_CREDENTIAL | 3 | Credential list page. | 28| PAGE_INSTALL_CERTIFICATE | 4 | Certificate installation page. | 29 30## CertificateDialogErrorCode 31 32Enumerates the error codes reported when the certificate management dialog box APIs are called. 33 34**System capability**: SystemCapability.Security.CertificateManagerDialog 35 36**Model restriction**: This API can be used only in the stage model. 37 38| Name | Value | Description | 39| ---------- | ------ | --------- | 40| ERROR_GENERIC | 29700001 | Internal error. | 41 42## certificateManagerDialog.openCertificateManagerDialog 43 44openCertificateManagerDialog(context: common.Context, pageType: CertificateDialogPageType): Promise\<void> 45 46Opens the certificate management dialog box and displays the page of the specified type. This API uses a promise to return the result. 47 48**Required permissions**: ohos.permission.ACCESS_CERT_MANAGER 49 50**System capability**: SystemCapability.Security.CertificateManagerDialog 51 52**Model restriction**: This API can be used only in the stage model. 53 54**Parameters** 55 56| Name | Type | Mandatory | Description | 57| -------- | ------------------------------------------------- | ---- | -------------------------- | 58| context | [common.Context](../apis-ability-kit/js-apis-app-ability-common.md) | Yes | Context of the application. | 59| pageType | [CertificateDialogPageType](#certificatedialogpagetype) | Yes | Type of the page to display. | 60 61**Return value** 62 63| Type | Description | 64| ------------------------------------------- | -------------------- | 65| Promise\<void> | Promise that returns no value. | 66 67**Error codes** 68 69For details about the error codes, see [Certificate Management Dialog Box Error Codes](errorcode-certManagerDialog.md). 70 71| ID | Error Message | 72| -------- | ------------------------------------------------------------ | 73| 201 | Permission verification failed. The application does not have the permission required to call the API. | 74| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 75| 29700001 | Internal error. | 76 77**Example** 78```ts 79import certificateManagerDialog from '@ohos.security.certManagerDialog'; 80import { BusinessError } from '@kit.BasicServicesKit'; 81import { common } from '@kit.AbilityKit'; 82 83/* context is application context information, which is obtained by the caller. The context here is only an example. */ 84let context: common.Context = getContext(this); 85/* pageType specifies the type of the page to display. In this example, pageType is PAGE_MAIN, which indicates the main page of the Certificate Management application. */ 86let pageType: certificateManagerDialog.CertificateDialogPageType = certificateManagerDialog.CertificateDialogPageType.PAGE_MAIN; 87try { 88 certificateManagerDialog.openCertificateManagerDialog(context, pageType).then(() => { 89 console.info('Succeeded in opening certificate manager dialog.'); 90 }).catch((err: BusinessError) => { 91 console.error(`Failed to open certificate manager dialog. Code: ${err.code}, message: ${err.message}`); 92 }) 93} catch (error) { 94 console.error(`Failed to open certificate manager dialog. Code: ${error.code}, message: ${error.message}`); 95} 96``` 97