【问题标题】:Is it possible to list installed certificates on Firefox?是否可以在 Firefox 上列出已安装的证书?
【发布时间】:2017-06-07 03:40:03
【问题描述】:

我需要获取/列出安装在 Mozilla Firefox 上的所有证书。我想知道是否可以使用 Selenium webdriver 管理它。

我找到了this answer 和存储证书的文件:

%appdata%/Mozilla/Firefox/<user.profile>/cert8.db

但我无法解析这种文件格式。那么,是否可以使用 Selenium 在 Firefox 上安装所有证书?

【问题讨论】:

    标签: python selenium selenium-webdriver


    【解决方案1】:

    您可以使用 Mozilla 的 certutil 工具来读取数据库。请注意,如果您在命令提示符下运行certutil,您将运行 Windows certutil,而不是 Mozilla 的。

    要运行 Mozilla 的 certutil,您需要从其存储库下载网络安全服务 (NSS),此处:

    https://ftp.mozilla.org/pub/security/nss/releases/

    但是 NSS 包需要 NSPR dll 才能正常运行。不知道为什么从 NSPR v4.6.2 开始,所有包都只是源包,没有所需的 dll,所以直接转到 v4.6.1 链接并下载缺少的 dll 压缩包。

    http://ftp.mozilla.org/pub/nspr/releases/v4.6.1/

    certutil.exe 和dll 放在同一个文件夹中后,运行以下命令:

    certutil.exe -L -d %appdata%\Mozilla\Firefox\Profiles\<profile_folder_name_here>
    

    地点:

    • -L:列出所有证书
    • -d:指定包含证书和密钥数据库文件的数据库目录

    有关其他 certutil 命令,请参见此处:

    https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/tools/NSS_Tools_certutil

    Python 脚本示例如下:

    import subprocess
    import os
    
    ff_prof_path = '{}\\Mozilla\\Firefox\\Profiles\\'.format(os.environ['APPDATA'])
    ff_prof_path = '{}{}'.format(ff_prof_path, os.listdir(ff_prof_path)[0])
    result = subprocess.run('certutil -L -d {}'.format(ff_prof_path), stdout=subprocess.PIPE)
    print(result.stdout.decode('utf-8'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-26
      • 1970-01-01
      • 2017-04-07
      • 2012-06-29
      • 2013-08-30
      • 2018-01-08
      • 2020-11-25
      • 2019-01-04
      相关资源
      最近更新 更多