homebrew 升级报错 LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443

报错信息

zqm:~ $ brew update
Warning: No available formula with the name "ca-certificates".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
Error: 
  homebrew-cask is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
zqm:~ $ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
fatal: unable to access 'https://github.com/Homebrew/homebrew-cask/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 
zqm:~ $ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
^C
zqm:~ $ 

原因:github现在使用token登录

vim .bash_profile
配置github的token: HOMEBREW_GITHUB_API_TOKEN
在这里插入图片描述

### SSLCertVerificationError 错误分析与解决方案 当遇到 `sslc.SSLCertVerificationError` 或 `[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed` 的错误时,这通常意味着 Python 在尝试通过 HTTPS 建立连接时无法验证远程服务器的 SSL 证书。这种问题可能由多种原因引起,包括但不限于: 1. **本地 CA 证书缺失或过期**:Python 使用内置的 CA 证书来验证远程服务器的身份。如果这些证书未更新,则可能导致此错误。 2. **网络代理干扰**:某些公司或机构可能会强制使用自签名证书作为中间人代理,从而导致认证失败。 3. **目标站点证书配置不当**:目标站点可能存在弱加密算法或其他技术缺陷。 以下是几种常见的解决方法及其适用场景: #### 方法一:更新 `certifi` 库 `certifi` 是一个提供最新 Mozilla CA Bundle 的第三方库,可以用来替代默认的 OpenSSL CA 文件。安装并升级它可以帮助修复因 CA 证书陈旧而导致的问题。 ```bash pip install --upgrade certifi ``` 之后,在代码中显式指定 `certifi` 提供的 CA 路径以确保加载最新的根证书集[^2]: ```python import ssl import certifi context = ssl.create_default_context(cafile=certifi.where()) response = urllib.request.urlopen('https://example.com', context=context) print(response.read().decode()) ``` #### 方法二:重新导入系统级信任存储中的CA数据到Python环境中 对于 macOS 用户来说,有时会因为操作系统的更新而使 Homebrew 安装的应用程序失去对新颁发机构的信任关系。可以通过运行以下命令恢复链接: ```bash /Applications/Python\ 3.x/Install\ Certificates.command ``` 注意替换路径里的版本号为实际使用的解释器版本号[^1]. #### 方法三:临时忽略SSL验证(仅用于测试目的!) 虽然不推荐在生产环境下关闭安全性检查,但在开发调试阶段确实有必要绕开繁琐的过程以便快速定位其他逻辑上的BUGs. 利用 requests 库发送请求时不校验HTTPS的真实性可通过设置参数verify=False实现;不过这样做存在极大安全隐患所以只限于内部封闭网段内的服务调用才可行[^4]: ```python import requests url = 'https://your-untrusted-site.example' r = requests.get(url, verify=False) # 不建议长期如此处理除非绝对确认风险可控且必要. if r.status_code == 200: print(r.text[:50]) else: raise Exception(f'Request failed with status {r.status_code}') ``` 另外也可以借助 curl 工具加上 `-k/--insecure` 参数达到相同效果即跳过公钥基础设施(PKI)链路完整性检测: ```bash curl -k https://api.moonshot.cn/v1 ``` #### 方法四:针对特定框架调整策略(PyTorch案例) 如果你是在 PyTorch 中下载预训练模型时遭遇此类异常的话,那么很可能是由于官方镜像站启用了更严格的TLS协议选项所致。此时除了上述通用手段外还可以考虑修改源地址指向国内加速节点或是手动提取权重文件再载入的方式规避潜在冲突[^3]: ```python from torchvision import models model = models.resnet50(pretrained=True, progress=True) ``` 以上就是关于如何应对SSLCertVerificationError (CERTIFICATE_VERIFY_FAILED)的一些思路分享啦! ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值