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 53662470844cafa16988e2c200239b828d1a83ac..45cb1aab4d9878c4d73ab348acb91d86bd1555e2 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 12a7b66c636680f1c0e8bd99ba9cc5916bf15bbb..cb77fbca5ef8270c8440f941668c39a8f6c2f055 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 0000000000000000000000000000000000000000..84977772fee92ac1f2579de3b6b8b7a7444a328f --- /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)。