Enterprise Data Guard Kit allows an app to update the enterprise public key certificate timely in scenarios such as certificate leakage or expiration.
For details about these APIs, please refer to the API Reference.
| API | Description |
|---|---|
| updateEnterpriseCertificate(signature: Uint8Array, cert: Uint8Array): Promise<number> | Updates the enterprise public key certificate using a promise. |
Import required modules.
import { BusinessError } from '@kit.BasicServicesKit';
import { recoveryKey } from '@kit.EnterpriseDataGuardKit';
import { hilog } from '@kit.PerformanceAnalysisKit'; Call the getAuthChallenge API to obtain a challenge and sign it. Then call the updateEnterpriseCertificate API and pass the challenge signature and enterprise public key certificate to update the certificate.
const TAG: string = 'EnterpriseRecoveryKey_Update';
const DOMAIN: number = 0x0000;
function testUpdateEnterpriseCertificate() {
// Replace signature with the real signature generated using the enterprise's public key, private key, and challenge.
let signature: Uint8Array = new Uint8Array([0]);
// Replace cert with the real enterprise certificate data.
let cert: Uint8Array = new Uint8Array([0]);
recoveryKey.updateEnterpriseCertificate(signature, cert).then((ret: number) => {
hilog.info(DOMAIN, TAG, `Succeeded in updating certificate. result is: ${ret}`);
}).catch((error: BusinessError) => {
hilog.error(DOMAIN, TAG, `Failed to update certificate. Code: ${error.code}, message: ${error.message}`);
});
}