【问题标题】:ca-certificates Mac OS Xca 证书 Mac OS X
【发布时间】:2021-12-30 04:41:13
【问题描述】:

我需要在emacs上安装offlineimap和mu4e。问题是配置。当我运行 offlineimap 时,我得到:

OfflineIMAP 6.5.5
Licensed under the GNU GPL v2+ (v2 or any later version)
Thread 'Account sync Gmail' terminated with exception:
Traceback (most recent call last):
File "/usr/local/Cellar/offline-imap/6.5.6/libexec/offlineimap/threadutil.py", line 158, in   run
Thread.run(self)
File "/anaconda/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/Cellar/offline-imap/6.5.6/libexec/offlineimap/accounts.py", line 226, in  syncrunner
self.remoterepos = Repository(self, 'remote')
File "/usr/local/Cellar/offline-imap/6.5.6/libexec/offlineimap/repository/__init__.py", line 78, in __new__
return repo(name, account)
File "/usr/local/Cellar/offline-imap/6.5.6/libexec/offlineimap/repository/Gmail.py", line 37, in __init__
IMAPRepository.__init__(self, reposname, account)
File "/usr/local/Cellar/offline-imap/6.5.6/libexec/offlineimap/repository/IMAP.py", line 34, in __init__
self.imapserver = imapserver.IMAPServer(self)
File "/usr/local/Cellar/offline-imap/6.5.6/libexec/offlineimap/imapserver.py", line 83, in __init__
self.sslcacertfile = repos.getsslcacertfile()
File "/usr/local/Cellar/offline-imap/6.5.6/libexec/offlineimap/repository/IMAP.py", line 211, in getsslcacertfile
% (self.name, cacertfile))
SyntaxWarning: CA certfile for repository 'Remote' could not be found. No such file: '/usr/share/curl/ca-bundle.crt.original'


Last 2 debug messages logged for Account sync Gmail prior to exception:
thread: Register new thread 'Account sync Gmail' (account 'Gmail')
imap: Using authentication mechanisms ['GSSAPI', 'CRAM-MD5', 'PLAIN', 'LOGIN']

这是我的 .offlineimaprc

[general]
accounts = Gmail
maxsyncaccounts = 1
pythonfile = ~/.offlineimap.py

[Account Gmail]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = ~/Maildir

[Repository Remote]
type = Gmail
remoteuser = enrico.pirani0@gmail.com
remotepasseval = get_password_emacs("imap.gmail.com", "enrico.pirani0@gmail.com", "993")
realdelete = no

folderfilter = lambda foldername: foldername not in ['[Gmail]/Spam', '[Gmail]/All Mail',    '[Gmail]/Starred', '[Gmail]/Important']

holdconnectionopen = true
keepalive = 60
sslcacertfile = /usr/share/curl/ca-bundle.crt.original #??

python 安装有问题,CA 证书有问题。关键是没有任何 curl-ca-bundle brew 包。我还有其他方法可以安装证书吗?

【问题讨论】:

    标签: python macos ssl


    【解决方案1】:

    我遇到了类似的问题(在 MacOS 10.10.2、openssl 1.0.2 和 offlineimap 6.5.5 上都来自自制软件)并且无法让虚拟证书解决方案正常工作。但是,我在/usr/local/etc/openssl/cert.pem 中发现了一个证书文件,它使offlineimap 停止抱怨(brew info openssl 告诉我,在通过自制软件安装 openssl 期间将其放在那里)。警告:我不知道这是否是一种好的或安全的方法。

    【讨论】:

    • 如果您通过自制软件安装了openssl,则此方法有效。因为它实际上是您钥匙串中安装的所有证书的导出,所以它也应该是一种安全的方式。
    • 谢谢@rudolfo.christ——我更新了答案。 certfile 路径中的/usr/local 应该告诉我它来自自制软件...
    • 我的(继承的)Mac 有 Homebrow 0.9.5,openssl: stable 1.0.2f。其中包含不会验证的/usr/local/etc/openssl/cert.pem,并且certs 目录为空。 brew reinstall openssl 没有帮助
    • 我将 curl https://curl.haxx.se/ca/cacert.pem > cacert.pem 放入 certs 目录,然后 /usr/local/opt/openssl/bin/c_rehash。还是不行,但是是因为“未知消息摘要算法”,所以这是一个好的开始
    【解决方案2】:

    OS X 上通常没有 CA 证书捆绑包,因为 SSL 库通常在内部使用 Apple 的安全框架并从 Keychain 获取证书。

    您可以从钥匙串证书创建自己的捆绑包:打开钥匙串,导航到“系统根”钥匙串中的“证书”类别,然后按 Command+Shift+E(“导出项目”),保存所有证书。我认为 Python 可以处理 PEM 格式,所以一定要选择它。

    或者,在 OS X 10.6 和更新版本上,系统 Python 是针对 OpenSSL 版本构建的,总是也会查看 Keychain。因此,您可以创建一个仅包含虚拟自签名证书的虚拟捆绑包,并在您的配置中使用它来关闭 OfflineIMAP。无论如何,它都会查看钥匙串证书。

    详情请见https://www.mercurial-scm.org/wiki/CACertificates#Mac_OS_X_10.6_and_higher

    【讨论】:

    • 是的,我在 Mercurial 中管理指向 ca-cert 的目录。现在好了。谢谢
    • 当我使用“系统根”时这对我不起作用,但是当我通过导出创建 Certificates.pem 时确实起作用(全选,ctrl-click 导出...) Keychains= "System" 和 Category="Certificates",并将其与 /usr/local/etc/openssl/cert.pem 中的内容连接起来。我们有一个奇怪的环境,组织有自己的证书,出于安全目的拦截和嗅探所有 SSL 流量,而这个证书在系统证书中;所有其他人都在 /usr/local/etc/openssl/cert.pem。
    【解决方案3】:

    一个简单的方法是使用 curl 证书包。我使用的是 MacPorts,所以这是通过端口 curl-ca-bundle 获得的

    sudo port install curl-ca-bundle
    

    然后你可以运行port contents curl-ca-bundle 来查看它安装了什么, 然后将以下内容添加到您的远程帐户部分中的~/.offlineimaprc

    sslcacertfile =/opt/local/share/curl/curl-ca-bundle.crt
    

    请注意,这也会将这些证书的链接设置为/opt/local/etc/openssl/cert.pem

    【讨论】:

      【解决方案4】:

      如果您安装了多个 openssl(例如 v1.0.2 和 1.1.1),则可能会发生这种情况。如果它们都是由brew 在某个时间点安装的,则必须将它们都卸载以消除冲突

      brew uninstall --ignore-dependencies --force openssl@1.1
      brew uninstall --ignore-dependencies --force openssl
      

      然后重新安装其中一个,比如

      brew install openssl@1.1
      

      希望这行得通!

      【讨论】:

      • 我没有冲突,但这让我走上了正确的道路,使用brew info openssl提供的路径,我启动并运行了它。
      【解决方案5】:

      我运行了@wood-guardian 给出的上述命令,然后运行解决问题。

      ruby -ropenssl -e "p OpenSSL::X509::DEFAULT_CERT_FILE"

      将上述语句的结果导出到 SSL_CERT_FILE 环境变量

      导出 SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem

      【讨论】:

      • 我整天都在寻找有关如何在 Gemfile 和捆绑安装问题中解决 CA 证书问题的答案。这解决了它。谢谢!
      【解决方案6】:

      对于 macOS 10.15.6(目前是 macOS 11 未来版本之前的最新稳定操作系统版本)我发现brew info openssl 是查找所有 CA 证书所在位置以及如何添加的最简单方便的方法您的自定义 CA .pem 证书。

      命令输出的剧透

      要添加其他证书,请将 .pem 文件放入 /usr/local/etc/openssl@1.1/certs

      然后运行/usr/local/opt/openssl@1.1/bin/c_rehash

      【讨论】:

        【解决方案7】:

        我在运行 10.6 的 Mac 上取得了成功,我更喜欢 Homebrew 生态系统,方法是使用 @patrick-sanan 的答案,然后在 Macports 生态系统版本的 cert.pem 中进行符号链接:

        sudo rm /usr/local/etc/openssl
        sudo ln -s /opt/local/etc/openssl/cert.pem /usr/local/etc/openssl
        

        【讨论】:

        • 注意我的 cert.pem 在我删除它时是空的
        【解决方案8】:

        我正在使用localhost gem,并将我的证书从~/.localhost/localhost.crt 添加到/usr/local/etc/openssl@1.1/cert.pem

        然后跑/usr/local/opt/openssl@1.1/bin/c_rehash

        可以通过以下方式进行测试:

        URI.open(URI.parse("https://localhost:3000"))
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-03-26
          • 2020-09-20
          • 2013-04-01
          • 1970-01-01
          • 2013-12-25
          • 2016-01-27
          相关资源
          最近更新 更多