4

我面临一个问题,我无法使用内置工具将证书私钥导入 monos 证书存储/密钥对存储certmgr

将证书公共版本添加到商店可以正常使用

user@maschine:~certs$ certmgr -add -c My MyCert.crt
Mono Certificate Manager - version 2.10.8.1
Manage X.509 certificates and CRL from stores.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

1 certificate(s) added to store My.

但是尝试添加相应的私钥以异常结束

user@maschine:~certs$ certmgr -add -c My MyCert.p12
Mono Certificate Manager - version 2.10.8.1
Manage X.509 certificates and CRL from stores.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.


Unhandled Exception: System.Security.Cryptography.CryptographicException: Invalid MAC - file may have been tampered!

尝试先添加公共版本 ( .cer),然后从私有版本 ( ) 导入相应的私钥.p12失败,但有一个稍微不同的例外:

user@maschine:~certs$ certmgr -add -c My MyCert.crt
Mono Certificate Manager - version 2.10.8.1
Manage X.509 certificates and CRL from stores.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

1 certificate(s) added to store My.
user@maschine:~certs$ certmgr -importKey -c My MyCert.p12
Mono Certificate Manager - version 2.10.8.1
Manage X.509 certificates and CRL from stores.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

Unhandled Exception: System.Security.Cryptography.CryptographicException: Improperly protected user's key pairs in '/var/licapp/.config/.mono/keypairs'.

使用密码保护证书(并将相应的参数添加到命令中)也无济于事。

我在 Debian Wheezy 上使用 mono V 2.10.8.1。有人知道如何在商店中添加句柄证书并使用 certmgr 处理他们的密钥对吗?

我正在考虑一种解决方法,我只将 p12 文件保留在我的应用程序下而不使用存储,我猜这将是一个更不干净的解决方案。但我无法将证书和密钥对都添加到商店。

顺便说一句,证书似乎还可以。将它们添加到 Windows 下的应用商店就可以了。

4

1 回答 1

4

文档存在一些问题,并且该工具的行为在某些地方有点奇怪或错误......

  1. 程序创建密钥对目录的权限设置错误。chmod 700 ~/.config/.mono/keypairs 解决了您列出的异常。
  2. 当您使用该-importKey操作时,您仍然必须指定对象类型证书,即使手册页没有说您必须使用对象类型。而且,没有“私钥”对象类型,而是使用“证书”对象类型(-c)。前任。certmgr -importKey -c -v -p p12password My CertAndKeyPair.p12给我一个成功的信息。
  3. 在第 2 步之后,证书/密钥将仍然无法访问。导入 P12 后,导入 DER 编码的证书。前任。certmgr -add -c My Certificate.cer这应该使证书/密钥可用于您的 .NET 代码。
  4. 如果您想将证书/密钥安装到机器存储 ( -m),您必须使用sudo.
于 2015-07-10T00:07:47.067 回答