From f2adc97d1aa9105e3135f1cc9b1f8aaf5aca5268 Mon Sep 17 00:00:00 2001 From: zhao_zhen_zhou Date: Fri, 28 Jul 2023 00:32:01 -0700 Subject: [PATCH] =?UTF-8?q?X509Cert.getSerialNumber=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=BA=9F=E5=BC=83=E5=8F=98=E6=9B=B4=E4=B8=BAX509Cert.getCertSe?= =?UTF-8?q?rialNumber?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhao_zhen_zhou --- .../reference/apis/js-apis-cert.md | 48 ++++++++++++++++++- .../security/cert-guidelines.md | 2 +- .../OpenHarmony_4.0.10.1/changelogs-cert.md | 35 ++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md diff --git a/zh-cn/application-dev/reference/apis/js-apis-cert.md b/zh-cn/application-dev/reference/apis/js-apis-cert.md index 5366247084..45cb1aab4d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-cert.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cert.md @@ -553,12 +553,16 @@ cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { }); ``` -### getSerialNumber +### getSerialNumber(deprecated) getSerialNumber() : number 表示获取X509证书序列号。 +> **说明:** +> +> 从API version 9开始支持,从API version 10开始废弃,建议使用[getCertSerialNumber](#getcertserialnumber10)替代。 + **系统能力:** SystemCapability.Security.Cert **返回值**: @@ -589,6 +593,48 @@ cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { }); ``` +### getCertSerialNumber10+ + +getCertSerialNumber() : bigint + +表示获取X509证书序列号。 + +**系统能力:** SystemCapability.Security.Cert + +**返回值**: + +| 类型 | 说明 | +| ------ | ------------------ | +| bigint | 表示X509证书序列号 | + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------- | +| 19020002 | runtime error. | + +**示例:** + +```js +import cryptoCert from '@ohos.security.cert'; + +// 证书二进制数据,需业务自行赋值 +let encodingData = null; +let encodingBlob = { + data: encodingData, + // 根据encodingData的格式进行赋值,支持FORMAT_PEM和FORMAT_DER + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + console.log("createX509Cert success"); + let serialNumber = x509Cert.getCertSerialNumber(); + } +}); +``` + ### getIssuerName getIssuerName() : DataBlob diff --git a/zh-cn/application-dev/security/cert-guidelines.md b/zh-cn/application-dev/security/cert-guidelines.md index 12a7b66c63..cb77fbca5e 100755 --- a/zh-cn/application-dev/security/cert-guidelines.md +++ b/zh-cn/application-dev/security/cert-guidelines.md @@ -34,7 +34,7 @@ | X509Cert | getPublicKey() : cryptoFramework.PubKey | 获取证书公钥 | | X509Cert | checkValidityWithDate(date: string) : void | 校验证书有效期 | | X509Cert | getVersion() : number | 获取证书版本 | -| X509Cert | getSerialNumber() : number | 获取证书序列号 | +| X509Cert | getCertSerialNumber() : bigint10+ | 获取证书序列号 | | X509Cert | getIssuerName() : DataBlob | 获取证书颁发者名称 | | X509Cert | getSubjectName() : DataBlob | 获取证书主体名称 | | X509Cert | getNotBeforeTime() : string | 获取证书有效期起始时间 | diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md new file mode 100644 index 0000000000..84977772fe --- /dev/null +++ b/zh-cn/release-notes/changelogs/OpenHarmony_4.0.10.1/changelogs-cert.md @@ -0,0 +1,35 @@ +# 安全子系统ChangeLog + +## cl.cert.1 X509Cert.getSerialNumber接口废弃变更 + +X509Cert.getSerialNumber接口作废弃处理,变更为X509Cert.getCertSerialNumber接口。 + +**变更影响** + +从API version 10开始,X509Cert.getSerialNumber接口废弃。应用需要自行适配为X509Cert.getCertSerialNumber。接口功能不变。 + +**关键的接口/组件变更** + +修改前的接口原型: + + ```js +interface X509Cert { + ... + getSerialNumber(): number; + ... +} + ``` + +修改后的接口原型: + + ```js +interface X509Cert { + ... + getCertSerialNumber(): bigint; + ... +} + ``` + +**适配指导** + +接口使用的示例代码可参考[证书开发指导](../../../application-dev/security/cert-guidelines.md)和[API参考](../../../application-dev/reference/apis/js-apis-cert.md)。 -- GitLab