未验证 提交 fed28a60 编写于 作者: O openharmony_ci 提交者: Gitee

!22424 [翻译完成】#I7OXOZ

Merge pull request !22424 from Annie_wang/PR21512
......@@ -553,12 +553,16 @@ cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
});
```
### getSerialNumber
### getSerialNumber<sup>(deprecated)</sup>
getSerialNumber() : number
Obtains the X.509 certificate serial number.
> **NOTE**
>
> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [getCertSerialNumber](#getcertserialnumber10).
**System capability**: SystemCapability.Security.Cert
**Return value**
......@@ -589,6 +593,48 @@ cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
});
```
### getCertSerialNumber<sup>10+</sup>
getCertSerialNumber() : bigint
Obtains the X.509 certificate serial number.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ------------------ |
| bigint | X.509 certificate serial number obtained.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------- |
| 19020002 | runtime error. |
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or 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
......
......@@ -34,7 +34,7 @@ The table below describes the APIs used in this guide.
| X509Cert | getPublicKey() : cryptoFramework.PubKey | Obtains the certificate public key. |
| X509Cert | checkValidityWithDate(date: string) : void | Checks the certificate validity period. |
| X509Cert | getVersion() : number | Obtains the certificate version. |
| X509Cert | getSerialNumber() : number | Obtains the certificate serial number. |
| X509Cert | getCertSerialNumber() : bigint<sup>10+</sup> | Obtains the certificate serial number.|
| X509Cert | getIssuerName() : DataBlob | Obtains the certificate issuer. |
| X509Cert | getSubjectName() : DataBlob | Obtains the certificate subject. |
| X509Cert | getNotBeforeTime() : string | Obtains the time from which the certificate takes effect. |
......@@ -489,7 +489,7 @@ function certChainValidatorSample() {
data: encodingData,
// Number of certificates. It is 2 in this example.
count: 2,
// Certificate format. PEM and DER are supported. In this example, the certificate is in PEM format.
// Certificate format. Only PEM and DER are supported. In this example, the certificate is in PEM format.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
......@@ -572,4 +572,4 @@ function crlEntrySample() {
}
});
}
```
```
\ No newline at end of file
# Security Subsystem Changelog
## cl.cert.1 X509Cert.getSerialNumber Deprecated
Deprecated **X509Cert.getSerialNumber()** and replaced it with **X509Cert.getCertSerialNumber()**.
**Change Impact**
**X509Cert.getSerialNumber()** is deprecated since API version 10. **X509Cert.getCertSerialNumber()** should be used to replace **X509Cert.getSerialNumber()** in application development. The API function remains unchanged.
**Key API/Component Changes**
API before change:
```js
interface X509Cert {
...
getSerialNumber(): number;
...
}
```
API after change:
```js
interface X509Cert {
...
getCertSerialNumber(): bigint;
...
}
```
**Adaptation Guide**
See [Certificate Development Guide](../../../application-dev/security/cert-guidelines.md) and [Certificate](../../../application-dev/reference/apis/js-apis-cert.md).
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册