# 生物认证

小程序通过 [SOTER](https://github.com/Tencent/soter) 提供以下生物认证方式。

目前支持指纹识别、人脸识别认证。设备支持的生物认证方式可使用 [wx.checkIsSupportSoterAuthentication](/miniprogram/dev/api/open-api/soter/wx.checkIsSupportSoterAuthentication.md) 查询。

## 调用流程

![](https://res8.wxqcloud.qq.com.cn/wxdoc/180a5c01-30cb-48ee-8f23-f9aa49d2ea2c.png)

## 流程步骤说明

1. 调用 [wx.startSoterAuthentication](/miniprogram/dev/api/open-api/soter/wx.startSoterAuthentication.md)，获取 `resultJSON` 和 `resultJSONSignature`。

2. （可选）签名校验。此处 `resultJSONSignature` 使用 SHA256withRSA/PSS 作为签名算法进行验签，公式定义如下：`验签结果 = verify(用于签名的原串，签名串，验证签名的公钥)`。

3. 微信提供后台接口用于可信的密钥验签服务，微信将保证该接口返回验签结果的正确性与可靠性；针对 Android root 场景，该接口同样会返回是否保证 root 情况下的安全性。

接口地址：

```
POST https://api.weixin.qq.com/cgi-bin/soter/verify_signature?access_token=%access_token
```

post 数据内容（JSON 编码）：

```json
{"openid":"$openid", "json_string" : "$resultJSON", "json_signature" : "$resultJSONSignature" }
```

请求返回数据内容（JSON 编码）：

```
// 验证成功返回
{"is_ok":true}
// 验证失败返回
{"is_ok":false}
// 接口调用失败
{"errcode":"xxx","errmsg":"xxxxx"}
```
