Python 是否可以列出Firefox上已安装的证书?

Python 是否可以列出Firefox上已安装的证书?,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我需要获取/列出Mozilla Firefox上安装的所有证书。我想知道是否可以使用SeleniumWebDriver管理它 我找到了存储证书的文件: %appdata%/Mozilla/Firefox//cert8.db 但是我不能解析这个文件格式。因此,是否可以使用Selenium在Firefox上安装所有证书?您可以使用Mozilla的certutil工具读取数据库。请注意,如果在命令提示符下运行certutil,您将运行的是Windows certutil,而不是Mozilla的 要运

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

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

%appdata%/Mozilla/Firefox//cert8.db

但是我不能解析这个文件格式。因此,是否可以使用Selenium在Firefox上安装所有证书?

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

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

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

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

certutil.exe -L -d %appdata%\Mozilla\Firefox\Profiles\<profile_folder_name_here>
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'))