Windows中用于公用和专用密钥的容器的位置? [英] Location of container for public and private keys in Windows?

查看:115
本文介绍了Windows中用于公用和专用密钥的容器的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码将公钥和私钥存储在容器中:

I am trying to store my public and private keys in a container using following code:

CspParameters cp = new CspParameters();
cp.KeyContainerName = "Test";
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);

我想知道的是容器的位置。容器在文件系统中的位置吗?

What I'd like to know is the location of the container. Is the location of the container in the file system?

推荐答案

您将在以下目录(*)中找到密钥文件:

You'll find the key files in the following directory (*):

Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), 
    @"Microsoft\Crypto\RSA\MachineKeys")

您可以获取给定密钥的文件名

You can get the filename for a given key as follows:

CspParameters cp = ...;
CspKeyContainerInfo info = new CspKeyContainerInfo(cp);
string fileName = info.UniqueKeyContainerName;

我不认为此信息已记录在案,因此如果您使用它,则将依赖未记录的实施细节,可能在将来的Windows版本中不起作用。不幸的是,有时有必要使用它。例如,在此问题中提到的,我不会认为还有其他可靠的方法可以从非特权帐户查看RSA密钥容器的权限。

I don't believe this information is documented, so if you use it you'll be relying on undocumented implementation details which may not work in future versions of Windows. Unfortunately, it's sometimes necessary to use it; for example as noted in this question, I don't think there's any other reliable way to view permissions for an RSA Key Container from a non-privileged account.

(*)用于机器密钥。用户特定的密钥大概在 Environment.SpecialFolder.LocalApplicationData

(*) that's for machine keys. User-specific keys are presumably under Environment.SpecialFolder.LocalApplicationData

这篇关于Windows中用于公用和专用密钥的容器的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆