请求报错如下
1 | panic: Post "https://oapi.dingtalk.com/robot/send?access_token=xxx": x509: certificate signed by unknown authority |
原因分析
由于使用了 scratch
做基础包, 里面没有和 https 相关的证书.
1 | FROM scratch |
解决方法
手动下载证书 ca-bundle.crt, 重命名为 ca-certificates.crt
后添加到 Image 镜像中:
1 | COPY ./ca-certificates.crt /etc/ssl/certs/ |
如果连接失效, google ca-certificates.crt download
查找相应信息.
参考: X509: Certificate Signed by Unknown Authority (Running a Go App Inside a Docker Container)