Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
0efc32f3
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0efc32f3
编写于
11月 24, 2022
作者:
H
heyinshen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean API doc warnings of cryptoFramework
Signed-off-by:
N
heyinshen
<
heyinshen1@huawei.com
>
上级
9a971821
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
221 addition
and
170 deletion
+221
-170
zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md
...application-dev/reference/apis/js-apis-cryptoFramework.md
+221
-170
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-cryptoFramework.md
浏览文件 @
0efc32f3
...
...
@@ -1181,6 +1181,13 @@ getEncoded() : DataBlob
**示例:**
```
js
function
uint8ArrayToShowStr
(
uint8Array
)
{
return
Array
.
prototype
.
map
.
call
(
uint8Array
,
(
x
)
=>
(
'
00
'
+
x
.
toString
(
16
)).
slice
(
-
2
))
.
join
(
''
);
}
let
key
;
// key为使用非对称密钥生成器生成的非对称密钥的公钥对象,此处省略生成过程
console
.
info
(
"
key format:
"
+
key
.
format
);
console
.
info
(
"
key algName:
"
+
key
.
algName
);
var
encodedKey
=
key
.
getEncoded
();
...
...
@@ -1217,6 +1224,13 @@ getEncoded() : DataBlob
**示例:**
```
js
function
uint8ArrayToShowStr
(
uint8Array
)
{
return
Array
.
prototype
.
map
.
call
(
uint8Array
,
(
x
)
=>
(
'
00
'
+
x
.
toString
(
16
)).
slice
(
-
2
))
.
join
(
''
);
}
let
key
;
// key为使用非对称密钥生成器生成的非对称密钥的私钥对象,此处省略生成过程
console
.
info
(
"
key format:
"
+
key
.
format
);
console
.
info
(
"
key algName:
"
+
key
.
algName
);
var
encodedKey
=
key
.
getEncoded
();
...
...
@@ -1234,6 +1248,7 @@ clearMem() : void
**示例:**
```
js
let
key
;
// key为使用非对称密钥生成器生成的非对称密钥的私钥对象,此处省略生成过程
key
.
clearMem
();
```
...
...
@@ -1562,6 +1577,8 @@ convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\<KeyPa
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
let
asyKeyGenerator
=
cryptoFramework
.
createAsyKeyGenerator
(
"
ECC256
"
);
let
pubKey
;
// pubKey为使用非对称密钥生成器生成的非对称密钥的公钥对象,此处省略生成过程
let
priKey
;
// priKey为使用非对称密钥生成器生成的非对称密钥的私钥对象,此处省略生成过程
asyKeyGenerator
.
convertKey
(
pubKey
,
priKey
,
(
err
,
keyPair
)
=>
{
if
(
err
)
{
console
.
error
(
"
convertKey: error.
"
);
...
...
@@ -1598,6 +1615,8 @@ convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\<KeyPair>
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
let
asyKeyGenerator
=
cryptoFramework
.
createAsyKeyGenerator
(
"
ECC256
"
);
let
pubKey
;
// pubKey为使用非对称密钥生成器生成的非对称密钥的公钥对象,此处省略生成过程
let
priKey
;
// priKey为使用非对称密钥生成器生成的非对称密钥的私钥对象,此处省略生成过程
let
keyGenPromise
=
asyKeyGenerator
.
convertKey
(
pubKey
,
priKey
);
keyGenPromise
.
then
(
keyPair
=>
{
console
.
info
(
"
convertKey success.
"
);
...
...
@@ -1987,12 +2006,21 @@ cipher.doFinal(data)
```
javascript
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
function
stringToUint8Array
(
str
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
return
new
Uint8Array
(
arr
);
}
let
rsaGenerator
=
cryptoFramework
.
createAsyKeyGenerator
(
"
RSA1024|PRIMES_2
"
);
let
cipher
=
cryptoFramework
.
createCipher
(
"
RSA1024|PKCS1
"
);
rsaGenerator
.
generateKeyPair
(
function
(
err
,
keyPair
)
{
let
pubKey
=
keyPair
.
pubKey
;
cipher
.
init
(
cryptoFramework
.
CryptoMode
.
ENCRYPT_MODE
,
pubKey
,
null
,
function
(
err
,
data
)
{
let
input
=
{
data
:
stringToUint8Array
(
plan
)
};
let
plainText
=
"
this is cipher text
"
;
let
input
=
{
data
:
stringToUint8Array
(
plainText
)
};
cipher
.
doFinal
(
input
,
function
(
err
,
data
)
{
AlertDialog
.
show
({
message
:
"
EncryptOutPut is
"
+
data
.
data
}
);
});
...
...
@@ -2005,6 +2033,14 @@ rsaGenerator.generateKeyPair(function (err, keyPair) {
```
javascript
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
function
stringToUint8Array
(
str
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
return
new
Uint8Array
(
arr
);
}
let
rsaGenerator
=
cryptoFramework
.
createAsyKeyGenerator
(
"
RSA1024|PRIMES_2
"
);
let
cipher
=
cryptoFramework
.
createCipher
(
"
RSA1024|PKCS1
"
);
let
keyGenPromise
=
rsaGenerator
.
generateKeyPair
();
...
...
@@ -2012,7 +2048,8 @@ keyGenPromise.then(rsaKeyPair => {
let
pubKey
=
rsaKeyPair
.
pubKey
;
return
cipher
.
init
(
cryptoFramework
.
CryptoMode
.
ENCRYPT_MODE
,
pubKey
,
null
);
// 传入私钥和DECRYPT_MODE可初始化解密模式
}).
then
(()
=>
{
let
input
=
{
data
:
stringToUint8Array
(
plan
)
};
let
plainText
=
"
this is cipher text
"
;
let
input
=
{
data
:
stringToUint8Array
(
plainText
)
};
return
cipher
.
doFinal
(
input
);
}).
then
(
dataBlob
=>
{
console
.
info
(
"
EncryptOutPut is
"
+
dataBlob
.
data
);
...
...
@@ -2169,13 +2206,15 @@ import cryptoFramework from "@ohos.security.cryptoFramework"
let
rsaGenerator
=
cryptoFramework
.
createAsyKeyGenerator
(
"
RSA1024|PRIMES_2
"
);
let
signer
=
cryptoFramework
.
createSign
(
"
RSA1024|PKCS1|SHA256
"
);
rsaGenerator
.
generateKeyPair
(
function
(
err
,
keyPair
)
{
globalKeyPair
=
keyPair
;
let
globalKeyPair
=
keyPair
;
let
priKey
=
globalKeyPair
.
priKey
;
let
input1
=
null
;
let
input2
=
null
;
signer
.
init
(
priKey
,
function
(
err
,
data
)
{
signer
.
update
(
input1
,
function
(
err
,
data
)
{
signer
.
sign
(
input2
,
function
(
err
,
data
)
{
S
ignMessageBlob
=
data
;
console
.
info
(
"
sign output is
"
+
SignMessageBlob
.
data
);
let
s
ignMessageBlob
=
data
;
console
.
info
(
"
sign output is
"
+
signMessageBlob
.
data
);
});
});
});
...
...
@@ -2190,8 +2229,10 @@ import cryptoFramework from "@ohos.security.cryptoFramework"
let
rsaGenerator
=
cryptoFramework
.
createAsyKeyGenerator
(
"
RSA1024|PRIMES_2
"
);
let
signer
=
cryptoFramework
.
createSign
(
"
RSA1024|PKCS1|SHA256
"
);
let
keyGenPromise
=
rsaGenerator
.
generateKeyPair
();
let
input1
=
null
;
let
input2
=
null
;
keyGenPromise
.
then
(
keyPair
=>
{
globalKeyPair
=
keyPair
;
let
globalKeyPair
=
keyPair
;
let
priKey
=
globalKeyPair
.
priKey
;
return
signer
.
init
(
priKey
);
}).
then
(()
=>
{
...
...
@@ -2199,8 +2240,8 @@ keyGenPromise.then( keyPair => {
}).
then
(()
=>
{
return
signer
.
sign
(
input2
);
}).
then
(
dataBlob
=>
{
S
ignMessageBlob
=
dataBlob
;
console
.
info
(
"
sign output is
"
+
S
ignMessageBlob
.
data
);
let
s
ignMessageBlob
=
dataBlob
;
console
.
info
(
"
sign output is
"
+
s
ignMessageBlob
.
data
);
});
```
...
...
@@ -2350,10 +2391,14 @@ verify(data : DataBlob, signatureData : DataBlob) : Promise\<boolean>
```
javascript
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
let
globalKeyPair
;
// globalKeyPair为使用非对称密钥生成器生成的非对称密钥对象,此处省略生成过程
let
input1
=
null
;
let
input2
=
null
;
let
signMessageBlob
=
null
;
let
verifyer
=
cryptoFramework
.
createVerify
(
"
RSA1024|PKCS1|SHA25
"
);
verifyer
.
init
(
globalKeyPair
.
pubKey
,
function
(
err
,
data
)
{
verifyer
.
update
(
input1
,
function
(
err
,
data
)
{
verifyer
.
verify
(
input2
,
S
ignMessageBlob
,
function
(
err
,
data
)
{
verifyer
.
verify
(
input2
,
s
ignMessageBlob
,
function
(
err
,
data
)
{
console
.
info
(
"
verify result is
"
+
data
);
})
});
...
...
@@ -2365,12 +2410,16 @@ verifyer.init(globalKeyPair.pubKey, function (err, data) {
```
javascript
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
let
globalKeyPair
;
// globalKeyPair为使用非对称密钥生成器生成的非对称密钥对象,此处省略生成过程
let
verifyer
=
cryptoFramework
.
createVerify
(
"
RSA1024|PKCS1|SHA256
"
);
let
verifyInitPromise
=
verifyer
.
init
(
globalKeyPair
.
pubKey
);
let
input1
=
null
;
let
input2
=
null
;
let
signMessageBlob
=
null
;
verifyInitPromise
.
then
(()
=>
{
return
verifyer
.
update
(
input1
);
}).
then
(()
=>
{
return
verifyer
.
verify
(
input2
,
S
ignMessageBlob
);
return
verifyer
.
verify
(
input2
,
s
ignMessageBlob
);
}).
then
(
res
=>
{
console
.
log
(
"
Verify result is
"
+
res
);
});
...
...
@@ -2452,6 +2501,7 @@ generateSecret(priKey : PriKey, pubKey : PubKey) : Promise\<DataBlob>
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
let
keyAgreement
=
cryptoFramework
.
createKeyAgreement
(
"
ECC256
"
);
let
globalKeyPair
;
// globalKeyPair为使用非对称密钥生成器生成的非对称密钥对象,此处省略生成过程
keyAgreement
.
generateSecret
(
globalKeyPair
.
priKey
,
globalKeyPair
.
pubKey
,
function
(
err
,
secret
)
{
if
(
err
)
{
console
.
error
(
"
keyAgreement error.
"
);
...
...
@@ -2467,6 +2517,7 @@ keyAgreement.generateSecret(globalKeyPair.priKey, globalKeyPair.pubKey, function
import
cryptoFramework
from
"
@ohos.security.cryptoFramework
"
let
keyAgreement
=
cryptoFramework
.
createKeyAgreement
(
"
ECC256
"
);
let
globalKeyPair
;
// globalKeyPair为使用非对称密钥生成器生成的非对称密钥对象,此处省略生成过程
let
keyAgreementPromise
=
keyAgreement
.
generateSecret
(
globalKeyPair
.
priKey
,
globalKeyPair
.
pubKey
);
keyAgreementPromise
.
then
((
secret
)
=>
{
console
.
info
(
"
keyAgreement output is
"
+
secret
.
data
);
...
...
@@ -2505,9 +2556,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
}
});
```
...
...
@@ -2545,9 +2596,9 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Cert
(
encodingBlob
).
then
(
x509Cert
=>
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
},
error
=>
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -2585,16 +2636,16 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
// 业务需通过AsyKeyGenerator生成PubKey或通过上级X509Cert证书对象的getPublicKey获取PubKey
let
pubKey
=
null
;
x509Cert
.
verify
(
pubKey
,
function
(
error
,
data
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
verify success
"
);
c
onsole
.
log
(
"
verify success
"
);
}
});
}
...
...
@@ -2634,16 +2685,16 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Cert
(
encodingBlob
).
then
(
x509Cert
=>
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
// 业务需通过AsyKeyGenerator生成PubKey或通过上级X509Cert证书对象的getPublicKey获取PubKey
let
pubKey
=
null
;
x509Cert
.
verify
(
pubKey
).
then
(
result
=>
{
C
onsole
.
log
(
"
verify success
"
);
c
onsole
.
log
(
"
verify success
"
);
},
error
=>
{
C
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -2676,14 +2727,14 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
x509Cert
.
getEncoded
(
function
(
error
,
data
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getEncoded success
"
);
c
onsole
.
log
(
"
getEncoded success
"
);
}
});
}
...
...
@@ -2717,14 +2768,14 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Cert
(
encodingBlob
).
then
(
x509Cert
=>
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
x509Cert
.
getEncoded
().
then
(
result
=>
{
C
onsole
.
log
(
"
getEncoded success
"
);
c
onsole
.
log
(
"
getEncoded success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -2757,14 +2808,14 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
x509Cert
.
getPublicKey
(
function
(
error
,
pubKey
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getPublicKey failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getPublicKey failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getPublicKey success
"
);
c
onsole
.
log
(
"
getPublicKey success
"
);
}
});
}
...
...
@@ -2798,14 +2849,14 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Cert
(
encodingBlob
).
then
(
x509Cert
=>
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
x509Cert
.
getPublicKey
().
then
(
pubKey
=>
{
C
onsole
.
log
(
"
getPublicKey success
"
);
c
onsole
.
log
(
"
getPublicKey success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getPublicKey failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getPublicKey failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -2839,15 +2890,15 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
date
=
"
150527000001Z
"
;
x509Cert
.
checkValidityWithDate
(
date
,
function
(
error
,
data
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
checkValidityWithDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
checkValidityWithDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
checkValidityWithDate success
"
);
c
onsole
.
log
(
"
checkValidityWithDate success
"
);
}
});
}
...
...
@@ -2887,15 +2938,15 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Cert
(
encodingBlob
).
then
(
x509Cert
=>
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
date
=
"
150527000001Z
"
;
x509Cert
.
checkValidityWithDate
(
date
).
then
(
result
=>
{
C
onsole
.
log
(
"
checkValidityWithDate success
"
);
c
onsole
.
log
(
"
checkValidityWithDate success
"
);
},
error
=>
{
C
onsole
.
log
(
"
checkValidityWithDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
checkValidityWithDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -2927,9 +2978,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
version
=
x509Cert
.
getVersion
();
}
});
...
...
@@ -2963,9 +3014,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
serialNumber
=
x509Cert
.
getSerialNumber
();
}
});
...
...
@@ -2999,9 +3050,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
issuerName
=
x509Cert
.
getIssuerName
();
}
});
...
...
@@ -3035,9 +3086,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
subjectName
=
x509Cert
.
getSubjectName
();
}
});
...
...
@@ -3071,9 +3122,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
notBefore
=
x509Cert
.
getNotBeforeTime
();
}
});
...
...
@@ -3107,9 +3158,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
notAfter
=
x509Cert
.
getNotAfterTime
();
}
});
...
...
@@ -3143,9 +3194,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
signature
=
x509Cert
.
getSignature
();
}
});
...
...
@@ -3179,9 +3230,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
sigAlgName
=
x509Cert
.
getSignatureAlgName
();
}
});
...
...
@@ -3215,9 +3266,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
sigAlgOid
=
x509Cert
.
getSignatureAlgOid
();
}
});
...
...
@@ -3251,9 +3302,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
sigAlgParams
=
x509Cert
.
getSignatureAlgParams
();
}
});
...
...
@@ -3287,9 +3338,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
keyUsage
=
x509Cert
.
getKeyUsage
();
}
});
...
...
@@ -3323,9 +3374,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
extKeyUsage
=
x509Cert
.
getExtKeyUsage
();
}
});
...
...
@@ -3359,9 +3410,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
basicConstraints
=
x509Cert
.
getBasicConstraints
();
}
});
...
...
@@ -3395,9 +3446,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
subjectAltNames
=
x509Cert
.
getSubjectAltNames
();
}
});
...
...
@@ -3431,9 +3482,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Cert
(
encodingBlob
,
function
(
error
,
x509Cert
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Cert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Cert success
"
);
c
onsole
.
log
(
"
createX509Cert success
"
);
let
issuerAltNames
=
x509Cert
.
getIssuerAltNames
();
}
});
...
...
@@ -3469,9 +3520,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
}
});
```
...
...
@@ -3509,9 +3560,9 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -3549,16 +3600,16 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需自行生成X509Cert证书对象
let
x509Cert
=
null
;
x509Crl
.
isRevoked
(
x509Cert
,
function
(
error
,
isRevoked
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
call isRevoked failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
call isRevoked failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
call isRevoked success
"
);
c
onsole
.
log
(
"
call isRevoked success
"
);
}
});
}
...
...
@@ -3598,16 +3649,16 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需自行生成X509Cert证书对象
let
x509Cert
=
null
;
x509Crl
.
isRevoked
(
x509Cert
).
then
(
isRevoked
=>
{
C
onsole
.
log
(
"
call isRevoked success
"
);
c
onsole
.
log
(
"
call isRevoked success
"
);
},
error
=>
{
C
onsole
.
log
(
"
call isRevoked failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
call isRevoked failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -3639,9 +3690,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
type
=
x509Crl
.
getType
();
}
});
...
...
@@ -3676,14 +3727,14 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
x509Crl
.
getEncoded
(
function
(
error
,
data
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getEncoded success
"
);
c
onsole
.
log
(
"
getEncoded success
"
);
}
});
}
...
...
@@ -3717,14 +3768,14 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
x509Crl
.
getEncoded
().
then
(
result
=>
{
C
onsole
.
log
(
"
getEncoded success
"
);
c
onsole
.
log
(
"
getEncoded success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -3758,16 +3809,16 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需通过AsyKeyGenerator生成PubKey
let
pubKey
=
null
;
x509Crl
.
verify
(
pubKey
,
function
(
error
,
data
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
verify success
"
);
c
onsole
.
log
(
"
verify success
"
);
}
});
}
...
...
@@ -3807,16 +3858,16 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需通过AsyKeyGenerator生成PubKey
let
pubKey
=
null
;
x509Crl
.
verify
(
pubKey
).
then
(
result
=>
{
C
onsole
.
log
(
"
verify success
"
);
c
onsole
.
log
(
"
verify success
"
);
},
error
=>
{
C
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
verify failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -3848,9 +3899,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
version
=
x509Crl
.
getVersion
();
}
});
...
...
@@ -3884,9 +3935,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
issuerName
=
x509Crl
.
getIssuerName
();
}
});
...
...
@@ -3920,9 +3971,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
lastUpdate
=
x509Crl
.
getLastUpdate
();
}
});
...
...
@@ -3956,9 +4007,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
nextUpdate
=
x509Crl
.
getNextUpdate
();
}
});
...
...
@@ -3994,16 +4045,16 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需赋值为对应证书的序列号
let
serialNumber
=
1000
;
x509Crl
.
getRevokedCert
(
serialNumber
,
function
(
error
,
entry
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getRevokedCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevokedCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getRevokedCert success
"
);
c
onsole
.
log
(
"
getRevokedCert success
"
);
}
});
}
...
...
@@ -4043,16 +4094,16 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需赋值为对应证书的序列号
let
serialNumber
=
1000
;
x509Crl
.
getRevokedCert
(
serialNumber
).
then
(
entry
=>
{
C
onsole
.
log
(
"
getRevokedCert success
"
);
c
onsole
.
log
(
"
getRevokedCert success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getRevokedCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevokedCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -4086,16 +4137,16 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需自行生成X509Cert证书对象
let
x509Cert
=
null
;
x509Crl
.
getRevokedCertWithCert
(
x509Cert
,
function
(
error
,
entry
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getRevokedCertWithCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevokedCertWithCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getRevokedCertWithCert success
"
);
c
onsole
.
log
(
"
getRevokedCertWithCert success
"
);
}
});
}
...
...
@@ -4135,16 +4186,16 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
// 业务需自行生成X509Cert证书对象
let
x509Cert
=
null
;
x509Crl
.
getRevokedCertWithCert
(
x509Cert
).
then
(
entry
=>
{
C
onsole
.
log
(
"
getRevokedCertWithCert success
"
);
c
onsole
.
log
(
"
getRevokedCertWithCert success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getRevokedCertWithCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevokedCertWithCert failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -4177,14 +4228,14 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
x509Crl
.
getRevokedCerts
(
function
(
error
,
array
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getRevokedCerts failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevokedCerts failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getRevokedCerts success
"
);
c
onsole
.
log
(
"
getRevokedCerts success
"
);
}
});
}
...
...
@@ -4218,14 +4269,14 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
x509Crl
.
getRevokedCerts
().
then
(
array
=>
{
C
onsole
.
log
(
"
getRevokedCerts success
"
);
c
onsole
.
log
(
"
getRevokedCerts success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getRevokedCerts failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevokedCerts failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -4258,14 +4309,14 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
x509Crl
.
getTbsInfo
(
function
(
error
,
tbsInfo
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getTbsInfo failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getTbsInfo failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getTbsInfo success
"
);
c
onsole
.
log
(
"
getTbsInfo success
"
);
}
});
}
...
...
@@ -4299,14 +4350,14 @@ let encodingBlob = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
cryptoFramework
.
createX509Crl
(
encodingBlob
).
then
(
x509Crl
=>
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
x509Crl
.
getTbsInfo
().
then
(
tbsInfo
=>
{
C
onsole
.
log
(
"
getTbsInfo success
"
);
c
onsole
.
log
(
"
getTbsInfo success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getTbsInfo failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getTbsInfo failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
},
error
=>
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -4338,9 +4389,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
signature
=
x509Crl
.
getSignature
();
}
});
...
...
@@ -4374,9 +4425,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
sigAlgName
=
x509Crl
.
getSignatureAlgName
();
}
});
...
...
@@ -4410,9 +4461,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
sigAlgOid
=
x509Crl
.
getSignatureAlgOid
();
}
});
...
...
@@ -4446,9 +4497,9 @@ let encodingBlob = {
};
cryptoFramework
.
createX509Crl
(
encodingBlob
,
function
(
error
,
x509Crl
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
createX509Crl failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
createX509Crl success
"
);
c
onsole
.
log
(
"
createX509Crl success
"
);
let
sigAlgParams
=
x509Crl
.
getSignatureAlgParams
();
}
});
...
...
@@ -4521,9 +4572,9 @@ let certChainData = {
};
validator
.
validate
(
certChainData
,
function
(
error
,
data
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
validate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
validate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
validate success
"
);
c
onsole
.
log
(
"
validate success
"
);
}
});
```
...
...
@@ -4566,9 +4617,9 @@ let certChainData = {
encodingFormat
:
cryptoFramework
.
EncodingFormat
.
FORMAT_PEM
};
validator
.
validate
(
certChainData
).
then
(
result
=>
{
C
onsole
.
log
(
"
validate success
"
);
c
onsole
.
log
(
"
validate success
"
);
},
error
=>
{
C
onsole
.
log
(
"
validate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
validate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -4623,9 +4674,9 @@ import cryptoFramework from '@ohos.security.cryptoFramework';
let
x509CrlEntry
=
null
;
x509CrlEntry
.
getEncoded
(
function
(
error
,
data
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getEncoded success
"
);
c
onsole
.
log
(
"
getEncoded success
"
);
}
});
```
...
...
@@ -4652,9 +4703,9 @@ import cryptoFramework from '@ohos.security.cryptoFramework';
// 业务需通过X509Crl的getRevokedCert相关方法获取X509CrlEntry
let
x509CrlEntry
=
null
;
x509CrlEntry
.
getEncoded
().
then
(
result
=>
{
C
onsole
.
log
(
"
getEncoded success
"
);
c
onsole
.
log
(
"
getEncoded success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getEncoded failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -4706,9 +4757,9 @@ import cryptoFramework from '@ohos.security.cryptoFramework';
let
x509CrlEntry
=
null
;
x509CrlEntry
.
getCertIssuer
(
function
(
error
,
issuer
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getCertIssuer failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getCertIssuer failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getCertIssuer success
"
);
c
onsole
.
log
(
"
getCertIssuer success
"
);
}
});
```
...
...
@@ -4735,9 +4786,9 @@ import cryptoFramework from '@ohos.security.cryptoFramework';
// 业务需通过X509Crl的getRevokedCert相关方法获取X509CrlEntry
let
x509CrlEntry
=
null
;
x509CrlEntry
.
getCertIssuer
().
then
(
issuer
=>
{
C
onsole
.
log
(
"
getCertIssuer success
"
);
c
onsole
.
log
(
"
getCertIssuer success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getCertIssuer failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getCertIssuer failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
...
...
@@ -4765,9 +4816,9 @@ import cryptoFramework from '@ohos.security.cryptoFramework';
let
x509CrlEntry
=
null
;
x509CrlEntry
.
getRevocationDate
(
function
(
error
,
date
)
{
if
(
error
!=
null
)
{
C
onsole
.
log
(
"
getRevocationDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevocationDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
}
else
{
C
onsole
.
log
(
"
getRevocationDate success
"
);
c
onsole
.
log
(
"
getRevocationDate success
"
);
}
});
```
...
...
@@ -4794,8 +4845,8 @@ import cryptoFramework from '@ohos.security.cryptoFramework';
// 业务需通过X509Crl的getRevokedCert相关方法获取X509CrlEntry
let
x509CrlEntry
=
null
;
x509CrlEntry
.
getRevocationDate
().
then
(
date
=>
{
C
onsole
.
log
(
"
getRevocationDate success
"
);
c
onsole
.
log
(
"
getRevocationDate success
"
);
},
error
=>
{
C
onsole
.
log
(
"
getRevocationDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
c
onsole
.
log
(
"
getRevocationDate failed, errCode:
"
+
error
.
code
+
"
, errMsg:
"
+
error
.
message
);
});
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录