无法导入以下密钥文件:tSQLtOfficialSigningKey.pfx 在 运行 构建 tSLQt 时

Cannot import the following key file: tSQLtOfficialSigningKey.pfx when running building tSLQt

我正尝试按照 tSQLt\Build\Install the tSQLt build.docx.

中的说明在本地 运行 tSQLt 解决方案

重建tSQLtCLR解决方案:

1>------ Rebuild All started: Project: tSQLtCLR, Configuration: Debug Any CPU ------
2>------ Rebuild All started: Project: tSQLtTestUtilCLR, Configuration: Debug Any CPU ------
3>------ Rebuild All started: Project: tSQLtExternalAccessKey, Configuration: Debug Any CPU ------
4>------ Rebuild All started: Project: UnsignedEmpty, Configuration: Debug Any CPU ------
1>  tSQLtCLR -> E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\bin\Debug\tSQLtCLR.dll
2>  tSQLtTestUtilCLR -> E:\Source\tSQLt\tSQLtCLR\tSQLtTestUtilCLR\bin\Debug\tSQLtTestUtilCLR.dll
3>  tSQLtExternalAccessKey -> E:\Source\tSQLt\tSQLtCLR\tSQLtExternalAccessKey\bin\Debug\tSQLtExternalAccessKey.dll
4>  UnsignedEmpty -> E:\Source\tSQLt\tSQLtCLR\UnsignedEmpty\bin\Debug\UnsignedEmpty.dll
========== Rebuild All: 4 succeeded, 0 failed, 0 skipped ==========

我已经创建了自签名证书:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

然后我创建了 pfx 文件:

openssl pkcs12 -export -out E:\Source\tSQLt\tSQLtCLR\OfficialSigningKey\tSQLtOfficialSigningKey.pfx -inkey key.pem -in cert.pem

然后我双击那个新的 pfx 文件并为当前用户导入它。

最后 运行 Menu / Tools / tSQLt local Dev_tSQL 并出现以下错误:

+-------------------+
: Starting BUILD    :
+-------------------+
NAnt 0.92 (Build 0.92.4543.0; release; 2012-06-09)
Copyright (C) 2001-2012 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///E:/Source/tSQLt/Build/tSQLt.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: all 


init:


init.tSQLt:

   [delete] Deleting directory 'E:\Source\tSQLt\Build\temp'.
    [mkdir] Creating directory 'E:\Source\tSQLt\Build\temp'.

clr.compile:

     [echo] Compile CLR Command: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" tSQLtCLR.csproj /p:Configuration=CruiseControl /nologo
     [exec] Build started 2019-08-11 10:47:46 AM.
     [exec] Project "E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj" on node 1 (default targets).
     [exec] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_C20B79DE0583A5C1 [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled. [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec] Done Building Project "E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj" (default targets) -- FAILED.
     [exec] 
     [exec] Build FAILED.
     [exec] 
     [exec] "E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj" (default target) (1) ->
     [exec] (ResolveKeySource target) -> 
     [exec]   C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_C20B79DE0583A5C1 [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec]   C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2482,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled. [E:\Source\tSQLt\tSQLtCLR\tSQLtCLR\tSQLtCLR.csproj]
     [exec] 
     [exec]     0 Warning(s)
     [exec]     2 Error(s)
     [exec] 
     [exec] Time Elapsed 00:00:00.49

BUILD FAILED

E:\Source\tSQLt\Build\tSQLt.build(53,4):
External Program Failed: cmd (return code was 1)

Total time: 0.8 seconds.

+-------------------+
: BUILD FAILED      :
+-------------------+

更新:

生成pfx文件后,在项目中替换了4个。之后我打开 tSQLtCLR 解决方案并转到每个项目属性(UnsignedEmpty 项目除外),然后转到 Signing 选项卡并在那里勾选“签署程序集”勾选,选择密钥。它要求输入密码我没有输入任何内容,只是单击确定,因为密钥是在没有密码的情况下创建的。然后我 clean/rebuild 解决方案并得到错误:

1>C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_FAD69C25E7450957
1>C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled.
2>C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_3A487AA7CCDAEF2F
2>C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled.
3>C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3325: Cannot import the following key file: tSQLtOfficialSigningKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_5C6CEC0DAE821947
3>C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3214,5): error MSB3321: Importing key file "tSQLtOfficialSigningKey.pfx" was canceled.
4>  UnsignedEmpty -> E:\Source\tSQLt\tSQLtCLR\UnsignedEmpty\bin\Debug\UnsignedEmpty.dll

密钥确实受密码保护。您需要在本地用自己的密钥覆盖它。

如果您计划在将来执行拉取请求,请确保在 Git 中将文件标记为异常。