picgo 上传图片提示 “unable to verify the first certificate”

1次阅读

共计 1986 个字符,预计需要花费 5 分钟才能阅读完成。

环境描述

服务端

  1. minio + nginx
  2. 域名证书生成来源 https://freessl.cn

客户端

  • picgo(使用 picgo-plugin-s3 插件)
    picgo 配置如下 (部分配置做了脱敏)
{
  "picBed": {
    "uploader": "aws-s3",
    "current": "aws-s3",
    "aws-s3": {
      "accessKeyID": "xxx",
      "secretAccessKey": "xxx",
      "bucketName": "images",
      "uploadPath": "{year}/{month}/{md5}.{extName}",
      "region": "home",
      "endpoint": "https://xxx.top:9000",
      "proxy": "","urlPrefix":"https://xxx.top","urlSuffix":"",
      "pathStyleAccess": true,
      "rejectUnauthorized": true,
      "acl": "public-read",
      "disableBucketPrefixToURL": false
    }
  },
  "picgoPlugins": {"picgo-plugin-s3": true}
}

问题描述

使用 picgo 上传到使用 minio 搭建的图床提示了如下异常

C:UserswuhunDesktop>picgo -v
1.5.7

C:UserswuhunDesktop>picgo upload 1.png
[PicGo INFO]: Before transform
[PicGo INFO]: Transforming... Current transformer is [path]
[PicGo INFO]: Before upload
[PicGo INFO]: Uploading... Current uploader is [aws-s3]
[PicGo ERROR]: 上传到 S3 存储发生错误,请检查网络连接和配置是否正确
[PicGo ERROR]: Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1677:34)
    at TLSSocket.emit (node:events:519:28)
    at TLSSocket._finishInit (node:_tls_wrap:1076:8)
    at ssl.onhandshakedone (node:_tls_wrap:862:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  '$metadata': {attempts: 1, totalRetryDelay: 0}
}
[PicGo WARN]: failed
[PicGo ERROR]: Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1677:34)
    at TLSSocket.emit (node:events:519:28)
    at TLSSocket._finishInit (node:_tls_wrap:1076:8)
    at ssl.onhandshakedone (node:_tls_wrap:862:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  '$metadata': {attempts: 1, totalRetryDelay: 0}
}

处理过程与发现

  1. 使用谷歌浏览器访问 minio,浏览器正常信任证书,没有危险警告
  2. 把证书来源换成 阿里云的测试证书 之后,其他配置不变,picgo 可以正常上传图片
  3. 将证书添加到 受信任的根证书颁发机构 后,也还是提示 “UNABLE_TO_VERIFY_LEAF_SIGNATURE”

我的问题

  1. 国内的免费证书现在都只有三个月,阿里云的证书虽然可以正常使用,但临期需要手动更换,之前 1 年有效期的时候还好,三个月有效期的话会比较麻烦。所以,不打算继续使用阿里云的免费证书
  2. 目前使用的证书来源于 https://freessl.cn,这个网站也是我关注的一个技术博主推流的,正好我也有这方便需求,通过 acme.sh 脚本也支持自动更新证书,因此才开始使用它的证书。目前这个网站颁布的证书除了在 picgo 上传图片时出了问题以外,我手上的两台电脑(windows11,mac os)都能在谷歌浏览器上正常不报危险警告地访问 minio 的 web 端(minio 的 web 端和 api 端使用的同一个证书),包括我配置在阿里云 cdn 域名的证书也是用的这个网站生成的,但 cdn 是好好的
  3. 想要请教一下各位,出现 “UNABLE_TO_VERIFY_LEAF_SIGNATURE” 的原因是什么以及解决方案

避免被攻击,就不暴露自己的域名了

正文完
 0