简体   繁体   English

配置NSS Signtool以与Thales HSM一起使用?

[英]Configure NSS Signtool to work with a Thales HSM?

I have a problem. 我有个问题。 My organization needs to perform code signing for the XPI file type. 我的组织需要对XPI文件类型执行代码签名。 The certificates and their private keys MUST be protected by a hardware security module. 证书及其私钥必须由硬件安全模块保护。 This is for security reasons. 这是出于安全原因。

The existing NSS Signtool provided by Mozilla we have not been able to find a way to get that tool, to recognize either a Java keystore, a CSP in Windows, or a keychain in Mac. Mozilla提供的现有NSS Signtool尚无法找到一种获取该工具的方法,无法识别Java密钥库,Windows中的CSP或Mac中的钥匙串。 All of the solutions researched point to requiring the key to be copied into a software database that NSS Signtool is configured to use by default. 研究的所有解决方案都要求将密钥复制到NSS Signtool默认配置为使用的软件数据库中。

I need to sign XPI file types, and the reason I am trying to find a solution that works with Java, windows CSP, or Mac keychain, is that my existing HSM technology from Thales, has those 3 options as interfaces to communicate with the module. 我需要签署XPI文件类型,而我试图找到一种适用于Java,Windows CSP或Mac钥匙串的解决方案的原因是,我现有的Thales HSM技术具有这3个选项作为与模块进行通信的接口。

I saw there was a Java based file called XPISigner, but the solution is no longer supported, and the only version we found for that works with a Luna HSM exclusively in a way that is not forward compatible with today's Java versions. 我看到有一个名为XPISigner的基于Java的文件,但不再支持该解决方案,并且我们发现的唯一版本仅与Luna HSM兼容,而该方式与当前的Java版本不兼容。

Has anyone managed to get an HSM protected key to work with NSS Signtool? 是否有人设法获得受HSM保护的密钥才能与NSS Signtool一起使用? Or have there been any mechanism to integrate NSS Signtool with a java keystore? 还是有任何机制将NSS Signtool与Java密钥库集成? (The idea with the java option is I could then manipulate said solution to work with my HSM) (使用java选项的想法是我可以然后操纵所述解决方案以与我的HSM一起使用)

Thanks! 谢谢!

I was able to cobble together a solution using nsscapi.dll compiled from a nss-3.13.6 build. 我能够使用从nss-3.13.6生成的nsscapi.dll拼凑出一个解决方案。 I then copied the additional library dependencies to my nss-3.20 build for use in my overall applicaiton. 然后,我将其他库依赖项复制到了nss-3.20构建中,以用于整个应用程序。

nsscapi.dll for the purpose of signing a piece of code, is a rudimentary PKCS11 to Capi module interface for NSS. 用于签名代码的nsscapi.dll是用于NSS的基本PKCS11至Capi模块接口。 It apparently has memory leak problems, but since the scope of my use of NSS is to simply sign an XPI file occasionally, I am ok with restarting that module occasionally. 它显然存在内存泄漏问题,但是由于我使用NSS的范围是偶尔仅对XPI文件进行签名,因此我可以偶尔重新启动该模块。

The solution involves: nss-3.20 built out using mozilla-build, and "make nss_build_all" from within the "nss" subfolder of this package. 该解决方案涉及:使用mozilla-build构建的nss-3.20,以及此软件包“ nss”子文件夹中的“ make nss_build_all”。

Visual Studio C++ Redistributable 2015 x86 version (32bit as 64bit doesn't work for this project). Visual Studio C ++可再发行的2015 x86版本(32位为64位不适用于该项目)。

Thales CAPI interface to windows (yes they have a direct PKCS11 module, but for my customized environment only CAPI and Java keystore are options so I didn't use the Thales PKCS11 module) Thales CAPI与Windows的接口(是的,它们具有直接的PKCS11模块,但是对于我的自定义环境,只有CAPI和Java密钥库是可选项,因此我没有使用Thales PKCS11模块)

The PATH environment variable was modified to point to the bin and lib folders within the NSS build. 修改了PATH环境变量,使其指向NSS构建中的bin和lib文件夹。

nsscapi.dll located in the nss-3.20\\dist\\WIN95xxx\\lib\\ folder was loaded into the NSS build using "modutil": 使用“ modutil”将位于nss-3.20 \\ dist \\ WIN95xxx \\ lib \\文件夹中的nsscapi.dll加载到NSS构建中:

modutil -dbdir "c:\apps\certs" -add "capi" -libfile "C:\Apps\nss-3.20\dist\WIN954.0_DBG.OBJ\lib\nsscapi.dll" -mechanisms RSA:DSA:RC2:RANDOM

I already had Thales configured to populate code signing certificates to CAPI so I had code signing certs in CAPI already. 我已经将Thales配置为向CAPI填充代码签名证书,因此我已经在CAPI中拥有代码签名证书。

I had to use the "certificates" snap in, in mmc.exe to view the current user "Personal" certificate store. 我必须使用mmc.exe中的“证书”管理单元来查看当前用户的“个人”证书存储。 Then modify the "friendly" name of the code signing certificate I want to use to something meaningfull like "test". 然后将我要使用的代码签名证书的“友好”名称修改为“ test”之类有意义的名称。 This is so that the NSSCAPI module can identify that certificate uniquely in the list that is has visibility to. 这样,NSSCAPI模块可以在具有可见性的列表中唯一地标识该证书。

After that step of changing the friendly name on one of my test code signing certificates, I used the NSS signtool to display the list of available certificates: 在更改我的测试代码签名证书之一上的友好名称的步骤之后,我使用NSS signtool显示可用证书的列表:

signtool -d "c:\apps\certs" -L

I unzipped a "test.xpi" file into the "test" subfolder of "c:\\apps\\certs" which is a sub folder name I just made up, you can use what you want. 我将“ test.xpi”文件解压缩到“ c:\\ apps \\ certs”的“ test”子文件夹中,该子文件夹是我刚刚创建的子文件夹名称,您可以使用所需的内容。

My list contained an entry: 我的清单包含一个条目:

  • Microsoft Certificate Store:test Microsoft证书存储:测试

the * denotes it is a valid cert that can be used for codesigning in NSS *表示它是可用于NSS中的代码签名的有效证书

I then used signtool to sign the code in my test XPI file: 然后,我使用signtool对测试XPI文件中的代码进行签名:

signtool -d "C:\Users\mlawson\AppData\Roaming\Mozilla\Firefox\Profiles\4jnnnb1y.default" -k "Microsoft Certificate Store":"test" test/

With success! 有了成功!

I apologize in advance if my formatting of this answer is off. 如果此答案的格式已关闭,我谨向您致歉。 This is my first time both posting to stack overflow, and answering a post (even if it was my own). 这是我第一次发帖至堆栈溢出,并回答一条发帖(即使这是我自己的)。 I glossed over some of the high level steps in this post to keep it brief as some of the bigger "how to" do things like building NSS, are documented on Mozilla's site already. 我掩饰了这篇文章中的一些高级步骤,以使其简短,因为Mozilla网站上已经记录了一些较大的“操作方法”,例如构建NSS。 Thales related configurations are documented by Thales, not relevant to explain how that is configured as my use case for their CAPI interface is custom and proprietary. 泰雷兹(Thales)记录了与泰雷兹(Thales)相关的配置,与解释泰米尔(Cale)CAPI接口的用例是自定义和专有的配置无关。 But the overall concept of using nsscapi.dll and this solution, applies really to anything that ties into MSCAPI and being able to use that with NSS is handy. 但是使用nsscapi.dll和此解决方案的总体概念确实适用于与MSCAPI相关的任何事物,并且能够与NSS一起使用是很方便的。 The nsscapi.dll can also be loaded into firefox "security devices" as a module so that firefox can use CAPI as well, though I don't know how well exactly... nsscapi.dll也可以作为模块加载到firefox“安全设备”中,以便firefox也可以使用CAPI,尽管我不知道到底有多好...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM