You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ubuntu:22.04 Docker镜像访问raw.githubusercontent.com证书SAN匹配异常

ubuntu:22.04 Docker镜像curl访问raw.githubusercontent.com的SSL SAN错误解决

问题详情

基于ubuntu:22.04构建镜像时,执行curl https://raw.githubusercontent.com/触发SSL错误:

SSL: no alternative certificate subject name matches target host name 'raw.githubusercontent.com'

但以下环境均可正常访问:

  • ubuntu:23.04 Docker镜像
  • 本地Ubuntu 22.04实体机/虚拟机
  • curlimages/curl:7.81.0镜像

通过openssl s_client -connect raw.githubusercontent.com:443验证,目标证书已包含正确的SAN字段,问题锁定为ubuntu:22.04镜像本身的配置异常。

可行解决办法

  • 更新镜像内CA证书:ubuntu:22.04可能预装过期或不完整的根CA证书,在Dockerfile中添加:
    RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && update-ca-certificates
    
  • 升级curl版本:ubuntu:22.04默认curl版本可能存在SNI解析兼容性问题,执行升级:
    RUN apt-get update && apt-get install -y --no-install-recommends curl
    
  • 修正DNS解析:镜像内置DNS可能返回错误IP,手动指定可靠DNS:
    RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf
    
  • 强制curl启用SNI:若旧版curl未默认开启SNI,执行curl时添加参数:
    curl --ssl https://raw.githubusercontent.com/
    

内容的提问来源于stack exchange,提问作者Eric Graf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 15:06:05