V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wuhunyu
V2EX  ›  程序员

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

  •  
  •   wuhunyu · 10 天前 · 672 次点击

    环境描述

    服务端

    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:\Users\wuhun\Desktop>picgo -v
    1.5.7
    
    C:\Users\wuhun\Desktop>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" 的原因是什么以及解决方案

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

    2 条回复
    julyclyde
        1
    julyclyde  
       10 天前
    你可以调用
    openssl s_client -connect server:port -noout -text
    (注意 connect 前边是单个横线,不是两个)

    看看从客户端视角,服务器到底出示了什么样的证书?是不是缺了中间层证书?
    wuhunyu
        2
    wuhunyu  
    OP
       8 天前
    @julyclyde 谢谢,缺失是有问题,公钥部分我使用的是 acme.sh 脚本生成的 [域名].cer ,但应该使用 fullchain.cer
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1265 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 23:24 · PVG 07:24 · LAX 16:24 · JFK 19:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.