이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
번역
원본
이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

X509Certificate2Collection.Find 메서드

X509FindType 열거형 및 findValue 개체로 지정된 검색 조건을 사용하여 X509Certificate2Collection 개체를 검색합니다.

네임스페이스:  System.Security.Cryptography.X509Certificates
어셈블리:  System(System.dll)
public X509Certificate2Collection Find(
	X509FindType findType,
	Object findValue,
	bool validOnly
)

매개 변수

findType
형식: System.Security.Cryptography.X509Certificates.X509FindType
X509FindType 값 중 하나입니다.
findValue
형식: System.Object
개체로서의 검색 조건입니다.
validOnly
형식: System.Boolean
검색에서 유효한 인증서만 반환하려면 true이고, 그렇지 않으면 false입니다.
예외조건
CryptographicException

findType가 잘못된 경우

사용자 상호 작용이 필요 없는 경우 이 메서드를 사용하여 X509Certificate2 개체를 찾을 수 있습니다. 사용자가 X509Certificate2 개체를 선택할 수 있도록 하려면 Find 메서드를 사용합니다.

계단식 또는 중첩 스타일에서 이 메서드를 사용하여 각 메서드 호출 시 보다 구체적인 검색 조건을 적용할 수 있습니다.

다음 코드 예제에서는 현재 사용자의 개인 인증서 저장소를 열어 유효한 인증서만 찾고 사용자가 인증서를 선택하도록 한 다음 인증서와 인증서 체인 정보를 콘솔에 씁니다. 출력은 사용자가 선택하는 인증서에 따라 달라집니다.


using System;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.IO;
using System.Security.Cryptography.X509Certificates;

class CertSelect
{
	static void Main()
	{

			X509Store store = new X509Store("MY",StoreLocation.CurrentUser);
			store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
			X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
			X509Certificate2Collection fcollection = (X509Certificate2Collection)collection.Find(X509FindType.FindByTimeValid,DateTime.Now,false);
			X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag.MultiSelection);
			Console.WriteLine("Number of certificates: {0}{1}",scollection.Count,Environment.NewLine);
			foreach (X509Certificate2 x509 in scollection)
			{
				try
				{
					byte[] rawdata = x509.RawData;
					Console.WriteLine("Content Type: {0}{1}",X509Certificate2.GetCertContentType(rawdata),Environment.NewLine);
					Console.WriteLine("Friendly Name: {0}{1}",x509.FriendlyName,Environment.NewLine);
					Console.WriteLine("Certificate Verified?: {0}{1}",x509.Verify(),Environment.NewLine);
					Console.WriteLine("Simple Name: {0}{1}",x509.GetNameInfo(X509NameType.SimpleName,true),Environment.NewLine);
					Console.WriteLine("Signature Algorithm: {0}{1}",x509.SignatureAlgorithm.FriendlyName,Environment.NewLine);
					Console.WriteLine("Private Key: {0}{1}",x509.PrivateKey.ToXmlString(false),Environment.NewLine);
					Console.WriteLine("Public Key: {0}{1}",x509.PublicKey.Key.ToXmlString(false),Environment.NewLine);
					Console.WriteLine("Certificate Archived?: {0}{1}",x509.Archived,Environment.NewLine);
					Console.WriteLine("Length of Raw Data: {0}{1}",x509.RawData.Length,Environment.NewLine);
					X509Certificate2UI.DisplayCertificate(x509);
					x509.Reset();
				}
				catch (CryptographicException)
				{
				   Console.WriteLine("Information could not be written out for this certificate.");
				}
			}
			store.Close();
	}
}


.NET Framework

4.5, 4, 3.5, 3.0, 2.0에서 지원

.NET Framework Client Profile

4, 3.5 SP1에서 지원

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008(서버 코어 역할은 지원되지 않음), Windows Server 2008 R2(서버 코어 역할은 SP1 이상에서 지원, Itanium은 지원되지 않음)

.NET Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

추가
© 2013 Microsoft. All rights reserved.