英文:
emsdk install fails with urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]
问题
我正在尝试在 Windows 下根据这里的说明安装 emsdk。
我使用的是 Windows 10.0.19045.2728,是全新安装并已更新的,在一个具有开放互联网访问权限的虚拟机中。我以管理员身份安装了Python 3.11.3,并将其添加到了 PATH 中。然后,我下载了emsdk 2023-04-03并解压缩到一个 emsdk 文件夹中,然后在 cmd.exe 中执行以下命令:
> emsdk install latest
将 SDK 别名 'latest' 解析为 '3.1.35'
将 SDK 版本 '3.1.35' 解析为 'sdk-releases-671550b5bdceee7bdb21493714f9a815aa5149a9-64bit'
正在安装 SDK 'sdk-releases-671550b5bdceee7bdb21493714f9a815aa5149a9-64bit'..
正在安装工具 'node-14.18.2-64bit'..
错误: 下载 URL 'https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/node-v14.18.2-win-x64.zip' 失败: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)>
警告: 可能是 SSL/TLS 问题。请更新或安装 Python 文件夹中提供的 2048 位或更高版本的 SSL 根证书,或访问 https://pypi.org/project/certifi/ 并重试。
错误: 安装失败!
我错过了什么?
我尝试过
pip install certifi
(成功,但没有解决问题)python emsdk.py install latest
(没有变化)- 使用 Python 3.9.13(没有变化)
- 在拥有相同网络访问权限的 Mint 21.1 虚拟机中(这个方法可行)
丑陋的解决方法:我成功地将以下补丁插入到 emsdk.py
的 download_file
开头:
if url.startswith("https://storage.googleapis.com/"): # TODO fix/remove me
url = "http"+url[5:] # 将 https 更改为 http # TODO fix/remove me
英文:
I'm trying to install emsdk under Windows according to instructions there.
I use Windows (10.0.19045.2728 freshly installed and updated, in a VM with open internet access). I install Python 3.11.3 (as admin with "Add python.exe to PATH"), download emsdk 2023-04-03 and unzip that to an emsdk folder, and in a cmd.exe prompt do
> emsdk install latest
Resolving SDK alias 'latest' to '3.1.35'
Resolving SDK version '3.1.35' to 'sdk-releases-671550b5bdceee7bdb21493714f9a815aa5149a9-64bit'
Installing SDK 'sdk-releases-671550b5bdceee7bdb21493714f9a815aa5149a9-64bit'..
Installing tool 'node-14.18.2-64bit'..
Error: Downloading URL 'https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/node-v14.18.2-win-x64.zip': <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)>
Warning: Possibly SSL/TLS issue. Update or install Python SSL root certificates (2048-bit or greater) supplied in Python folder or https://pypi.org/project/certifi/ and try again.
error: installation failed!
What am I missing?
I tried
pip install certifi
(that succeeds, but does not cure it)python emsdk.py install latest
(no change)- using Python 3.9.13 (no change)
- under a Mint 21.1 VM with the same network access (it worked)
Ugly workaround: I successfully inserted this kludge in emsdk.py
at start of download_file
if url.startswith("https://storage.googleapis.com/"): # TODO fix/remove me
url = "http"+url[5:] # change https to http # TODO fix/remove me
答案1
得分: 0
以下是代码的中文翻译:
赞扬yolw:运行他们的PowerShell脚本可以永久解决这个问题!稍作编辑:
# 这似乎会更新机器证书存储,以便Python可以按Emscripten的要求下载文件
$WebsiteURL = "storage.googleapis.com"
Try {
$Conn = New-Object System.Net.Sockets.TcpClient($WebsiteURL, 443)
Try {
$Stream = New-Object System.Net.Security.SslStream($Conn.GetStream())
$Stream.AuthenticateAsClient($WebsiteURL)
$Cert = $Stream.Get_RemoteCertificate()
$ValidTo = [datetime]::Parse($Cert.GetExpirationDatestring())
Write-Host "`n连接成功" -ForegroundColor DarkGreen
Write-Host "网站: $WebsiteURL"
Write-Host "有效期至: $ValidTo"
}
Catch { Throw $_ }
Finally { $Conn.close() }
}
Catch {
Write-Host "`n连接到 $($WebsiteURL) 时发生错误" -ForegroundColor Yellow
Write-Host "网站: $WebsiteURL"
Write-Host "状态:" $_.exception.innerexception.message -ForegroundColor Yellow
Write-Host ""
}
要将此保存为update-machine-certs.ps1
,我需要执行以下命令:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
之后,我用以下命令撤销了设置:
Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser
输出如下:
连接成功
网站: storage.googleapis.com
有效期至: 06/12/2023 10:29:06
英文:
Kudos to yolw: running their powershell script fixes it for good! Slightly edited:
# This seems to update the machine cert store so that python can download the files as required by emscripten's install
$WebsiteURL="storage.googleapis.com"
Try {
$Conn = New-Object System.Net.Sockets.TcpClient($WebsiteURL,443)
Try {
$Stream = New-Object System.Net.Security.SslStream($Conn.GetStream())
$Stream.AuthenticateAsClient($WebsiteURL)
$Cert = $Stream.Get_RemoteCertificate()
$ValidTo = [datetime]::Parse($Cert.GetExpirationDatestring())
Write-Host "`nConnection Successfull" -ForegroundColor DarkGreen
Write-Host "Website: $WebsiteURL"
Write-Host "ValidTo: $ValidTo"
}
Catch { Throw $_ }
Finally { $Conn.close() }
}
Catch {
Write-Host "`nError occurred connecting to $($WebsiteURL)" -ForegroundColor Yellow
Write-Host "Website: $WebsiteURL"
Write-Host "Status:" $_.exception.innerexception.message -ForegroundColor Yellow
Write-Host ""
}
To get this saved as update-machine-certs.ps1
running, I needed to issue
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
that I undid with
Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser
The output was
Connection Successfull
Website: storage.googleapis.com
ValidTo: 06/12/2023 10:29:06
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论