2015-02-09 112 views
3

我面臨一個問題,我無法使用內置工具certmgr將證書私鑰導入monos certificatestore/keypairstore。如何使用單聲道certmgr導入自簽名證書的私鑰

添加證書公版到店工作正常使用

[email protected]:~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. 

但是嘗試添加相應的專用密鑰在異常

[email protected]:~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! 

試圖增加公共Verison結束(.cer ),然後從私有版本(.p12)導入相應的私鑰失敗,但與 例外情況略有不同:

[email protected]:~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. 
[email protected]:~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文件保存在我的應用程序下面,而不使用存儲,這將是一個更不潔的解決方案,我猜。但我只是無法將證書和密鑰對添加到商店。

Certificats似乎順利btw。將它們添加到Windows下的Store中工作得很好。

回答

3

有一些問題的文檔和工具的行爲有點古怪或錯誤的地方......當 程序創建他們

  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