인증서의 개인 키가 하드웨어 장치에 저장되어 있는지 여부를 확인하고자합니다.
는 이제 내가 찾는 정보는 r.CspKeyContainerInfo.HardwareDevice
에 다음 응용 프로그램장치가없는 하드웨어 장치에 개인 키가 있는지 확인하십시오.
class Program
{
static void Main(string[] args)
{
try
{
X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
foreach (X509Certificate2 x509 in store.Certificates)
{
if (x509.HasPrivateKey)
{
AsymmetricAlgorithm a = x509.PrivateKey;
RSACryptoServiceProvider r = a as RSACryptoServiceProvider;
if (null != r)
{
System.Console.WriteLine("hardware: " + r.CspKeyContainerInfo.HardwareDevice);
System.Console.WriteLine("Subject: " + x509.Subject);
System.Console.WriteLine("container: " + r.CspKeyContainerInfo.KeyContainerName);
System.Console.WriteLine("---");
}
}
}
}
catch (CryptographicException ex)
{
Console.WriteLine("Information could not be written out for this certificate.");
}
}
}
을 가정 해 봅시다.
하지만 불행히도 기본 스마트 카드 csp가 제공하는 상점의 경우 AsymmetricAlgorithm a = x509.PrivateKey
이 실행되면 해당 카드를 삽입하라는 메시지가 나타납니다 (이때 카드 리더가없는 경우).
이 성가신 "스마트 카드를 삽입하십시오"대화 상자가 나타나지 않고 동일한 정보를 얻을 수있는 방법이 있습니까?