Skip to content
欢迎扫码关注公众号

微信小程序接口调用 600001 错误修复

在微信开发者工具中无论是否开启 不校验合法域名、web-view(业务域名)、TLS 版本以及 HTTPS 证书 ,接口都可以正常访问,但是真机调试或通过发布的体验版访问时,所有接口都返回 600001 的错误。

json
{
    "errno": 600001,
    "errMsg": "request:fail -101:net:ERR_CONNECTION_R ESET"
}

查了几个文章都说是 HTTPS 证书的问题,但是对应公众号的网页也是用的同一个二级域名,通过浏览器是可以正常访问的。

架构上,服务部署在腾讯云的容器服务上,证书是部署在 ingress 上,证书内容配置在 secret 中,ingress class 使用的 Nginx Ingress ,HTTPS 证书使用的腾讯云免费的 SSL 证书。

对比了下其它小程序可以正常访问的 secret 配置,发现 tls.key 的内容是一样的,但是 tls.crt 的内容不一样。

正常小程序可以访问的 tls.crt 格式:

txt
-----BEGIN CERTIFICATE-----
MIIGbD********WhAg==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFBz********XH0g==
-----END CERTIFICATE-----

而我这次使用的格式:

txt
-----BEGIN CERTIFICATE-----
MIIGbD********WhAg==
-----END CERTIFICATE-----

这才发现我下载下来的是 Apache 版本的证书,而不是之前使用的 Nginx 版本的证书。

Apache 版本的证书将 crt 的内容分成了两个文件 域名.crtroot_bundle.crtNginx 版则是将这两个合成了一个文件 域名_bundle.crt

而我只将 Apache 版本证书的 域名.crt 的内容配置到了 tls.crt ,少了 root_bundle.crt 的内容,从而导致 HTTPS 请求握手时发生了错误。

tls.crt 的内容修改为 域名_bundle.crt 的内容后,小程序就可以正常调用接口了。

2023/03/28 追记

之前腾讯云提供的免费 SSL 证书是 TrustAsia 的,阿里云的免费证书是 DigiCert 的。下载下来的证书文件和腾讯云的并不一样,因为 Nginx Ingress 需要的是 .crt.key 文件,所以下载了阿里云 Apache 版的证书文件,但是仍然有些区别。Apache 版提供了两个 .crt 文件,分别是 xxx.xxx_public.crtxxx.xxx_chain.crt 两个文件,需要将这个文件合并后放到 Secret 的 tls.crt 中。不确定顺序有没有影响,我这边是先 public.crtchain.crt 的顺序。

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.