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

Hyper-V部署CentOS-9-Stream执行dnf命令出现SSL错误如何解决

CentOS Stream 9 DNF SSL证书错误解决办法

出现的Curl error (60)是系统无法验证HTTPS仓库的SSL证书导致的,以下是可行的解决步骤:

1. 检查并同步系统时间

证书验证对系统时间敏感,时间偏差过大直接会导致验证失败:

  • 查看当前系统时间:
    timedatectl
    
  • 启用NTP同步并重启服务:
    timedatectl set-ntp true
    systemctl restart chronyd
    
  • 确认同步状态:
    timedatectl status
    

2. 重新安装并更新CA证书

系统根证书缺失或损坏也会引发这个问题:

  • 临时禁用SSL验证来重装CA证书包:
    dnf reinstall ca-certificates -y --setopt=sslverify=false
    
  • 更新证书缓存:
    update-ca-trust extract
    

3. 临时禁用SSL验证(仅应急使用)

如果上述方法暂时无效,可以临时绕过SSL验证完成操作,但不建议长期使用:

  • 单次命令添加参数:
    dnf update -y --setopt=sslverify=false
    # 安装软件同理
    dnf install java-17-openjdk-headless -y --setopt=sslverify=false
    
  • 若需长期禁用(谨慎操作),编辑/etc/dnf/dnf.conf,添加一行:
    sslverify=false
    

4. 更换国内镜像源

部分情况下官方镜像的证书解析存在问题,更换国内镜像可解决:

  • 备份原BaseOS仓库配置:
    mv /etc/yum.repos.d/CentOS-BaseOS.repo /etc/yum.repos.d/CentOS-BaseOS.repo.bak
    
  • 创建阿里云镜像配置文件:
    cat > /etc/yum.repos.d/CentOS-BaseOS.repo << EOF
    [baseos]
    name=CentOS Stream 9 - BaseOS
    baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/
    gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official
    enabled=1
    EOF
    
  • 清理缓存并生成新缓存:
    dnf clean all && dnf makecache
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 04:52:46