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

!8897 【新增特性】支持webview的https的双向校验

Merge pull request !8897 from zhangb/master
......@@ -1411,6 +1411,114 @@ onHttpAuthRequest(callback: (event?: { handler: HttpAuthHandler, host: string, r
}
}
```
### onSslErrorEventReceive<sup>9+</sup>
onSslErrorEventReceive(callback: (event: { handler: SslErrorHandler, error: SslError }) => void)
通知用户加载资源时发生SSL错误。
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | ---------------- |
| handler | [SslErrorHandler](#sslerrorhandler9) | 通知Web组件用户操作行为。 |
| error | [SslError](#sslerror9枚举说明) | 错误码。 |
**示例:**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController();
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onSslErrorEventReceive((event) => {
AlertDialog.show({
title: 'onSslErrorEventReceive',
message: 'text',
primaryButton: {
value: 'confirm',
action: () => {
event.handler.handleConfirm();
}
},
secondaryButton: {
value: 'cancel',
action: () => {
event.handler.handleCancel();
}
},
cancel: () => {
event.handler.handleCancel();
}
})
return true;
})
}
}
}
```
### onClientAuthenticationRequest<sup>9+</sup>
onClientAuthenticationRequest(callback: (event: {handler : ClientAuthenticationHandler, host : string, port : number, keyTypes : Array<string>, issuers : Array<string>}) => void)
通知用户收到SSL客户端证书请求事件。
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | ---------------- |
| handler | [ClientAuthenticationHandler](#clientauthenticationhandler9) | 通知Web组件用户操作行为。|
| host | string | 请求证书服务器的主机名。 |
| port | number | 请求证书服务器的端口号。 |
| keyTypes| Array<string> | 可接受的非对称秘钥类型。 |
| issuers | Array<string> | 与私钥匹配的证书可接受颁发者。|
**示例:**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController();
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.onClientAuthenticationRequest((event) => {
AlertDialog.show({
title: 'onClientAuthenticationRequest',
message: 'text',
primaryButton: {
value: 'confirm',
action: () => {
event.handler.confirm("/system/etc/user.pk8", "/system/etc/chain-user.pem");
}
},
secondaryButton: {
value: 'cancel',
action: () => {
event.handler.cancel();
}
},
cancel: () => {
event.handler.ignore();
}
})
return true;
})
}
}
}
```
### onPermissionRequest<sup>9+</sup>
onPermissionRequest(callback: (event?: { request: PermissionRequest }) => void)
......@@ -2017,6 +2125,51 @@ isHttpAuthInfoSaved(): boolean
| ------- | ------------------------- |
| boolean | 存在密码认证成功返回true,其他返回false。 |
## SslErrorHandler<sup>9+</sup>
Web组件返回的SSL错误通知事件用户处理功能对象。示例代码参考[onSslErrorEventReceive事件](#onsslerroreventreceive9)
### handleCancel<sup>9+</sup>
handleCancel(): void
通知Web组件取消此请求。
### handleConfirm<sup>9+</sup>
handleConfirm(): void
通知Web组件继续使用SSL证书。
## ClientAuthenticationHandler<sup>9+</sup>
Web组件返回的SSL客户端证书请求事件用户处理功能对象。示例代码参考[onClientAuthenticationRequest事件](#onclientauthenticationrequest9)
### confirm<sup>9+</sup>
confirm(priKeyFile : string, certChainFile : string): void
通知Web组件使用指定的私钥和客户端证书链。
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | ------ | ---- | ---------- |
| priKeyFile | string | 是 | 存放私钥的文件,包含路径和文件名。|
| certChainFile | string | 是 | 存放证书链的文件,包含路径和文件名。|
### cancel<sup>9+</sup>
cancel(): void
通知Web组件取消相同host和port服务器发送的客户端证书请求事件。同时,相同host和port服务器的请求,不重复上报该事件。
### ignore<sup>9+</sup>
ignore(): void
通知Web组件忽略本次请求。
## PermissionRequest<sup>9+</sup>
Web组件返回授权或拒绝权限功能的对象。示例代码参考[onPermissionRequest事件](#onpermissionrequest9)
......@@ -3083,6 +3236,60 @@ clearHistory(): void
}
```
### clearSslCache
clearSslCache(): void
清除Web组件记录的SSL证书错误事件对应的用户操作行为。
**示例:**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController();
build() {
Column() {
Button('clearSslCache')
.onClick(() => {
this.controller.clearSslCache();
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### clearClientAuthenticationCache
clearClientAuthenticationCache(): void
清除Web组件记录的客户端证书请求事件对应的用户操作行为。
**示例:**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController();
build() {
Column() {
Button('clearClientAuthenticationCache')
.onClick(() => {
this.controller.clearClientAuthenticationCache();
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### getCookieManager<sup>9+</sup>
getCookieManager(): WebCookie
......@@ -4702,6 +4909,17 @@ onRenderExited接口返回的渲染进程退出的具体原因。
| Map | 地理地址。 |
| Unknown | 未知内容。 |
## SslError<sup>9+</sup>枚举说明
onSslErrorEventReceive接口返回的SSL错误的具体原因。
| 名称 | 描述 |
| -------------- | ----------------- |
| Invalid | 一般错误。 |
| HostMismatch | 主机名不匹配。 |
| DateInvalid | 证书日期无效。 |
| Untrusted | 证书颁发机构不受信任。 |
## ProtectedResourceType<sup>9+</sup>枚举说明
| 名称 | 描述 | 备注 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册