CocoaPods 安装错误:“证书 B:证书验证失败”
Posted
技术标签:
【中文标题】CocoaPods 安装错误:“证书 B:证书验证失败”【英文标题】:CocoaPods installation error: "certificate B: certificate verify failed" 【发布时间】:2022-01-22 08:04:36 【问题描述】:我想试试 Flutter。 flutter doctor
告诉我我需要 CocoaPods:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.6.1 20G224 darwin-x64, locale en-US)
[✓] android toolchain - develop for Android devices (Android SDK version 32.0.0)
[!] Xcode - develop for ios and macOS (Xcode 13.2.1)
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to
your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for
instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
好的,我只需要 CocoaPods!
我去了https://guides.cocoapods.org/using/getting-started.html#installation并首先尝试了这个:
sudo gem install cocoapods
这返回了一条错误消息:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
接下来我尝试了无 sudo 安装。我打开了我的.bash_profile
并添加了两行:
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
然后我又跑了gem install cocoapods
,没有sudo
:
gem install cocoapods
这返回了相同的错误消息:
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
我检查了rvm
,好像安装正确:
rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
我不知道server certificate B
是什么或如何解决它。我现在该怎么办?
【问题讨论】:
【参考方案1】:这行得通:
rvm osx-ssl-certs update all
它更新了 Ruby 认证。然后我不得不更新 Ruby,然后我安装了 CocoaPods。我没有使用sudo
,而是在.bash_profile
中安装了CocoaPods 的路径:
# for Cocoapods
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
然后我安装了 CocoaPods:
gem install cocoapods
我跑了flutter doctor
:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 11.6.1 20G224 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (1 available)
耶!
【讨论】:
以上是关于CocoaPods 安装错误:“证书 B:证书验证失败”的主要内容,如果未能解决你的问题,请参考以下文章
SSL_connect 返回=1 errno=0 state=SSLv3 读取服务器证书B:证书验证失败