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

!22426 [翻译完成】#I7OYGG

Merge pull request !22426 from Annie_wang/PR21556
......@@ -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
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册