当前位置: 首页>>代码示例>>C#>>正文


C# X509FindType类代码示例

本文整理汇总了C#中X509FindType的典型用法代码示例。如果您正苦于以下问题:C# X509FindType类的具体用法?C# X509FindType怎么用?C# X509FindType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


X509FindType类属于命名空间,在下文中一共展示了X509FindType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFindValue

        /// <summary>
        /// Gets the find value.
        /// </summary>
        /// <param name="findType">Type of the find.</param>
        /// <param name="value">The value.</param>
        /// <returns>The find value formated as string.</returns>
        public static string GetFindValue(X509FindType findType, X509Certificate2 value)
        {
            string findValue = null;

            switch (findType)
            {
                case X509FindType.FindBySubjectDistinguishedName:
                    findValue = GetSubjectDistinguishedName(value.SubjectName.Name);
                    break;
                case X509FindType.FindByThumbprint:
                    findValue = value.Thumbprint;
                    break;
                case X509FindType.FindBySubjectName:
                    findValue = value.SubjectName.Name;
                    break;
                case X509FindType.FindBySerialNumber:
                    findValue = value.SerialNumber;
                    break;
                default:
                    findValue = value.ToString(false);
                    break;
            }

            return findValue;
        }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:31,代码来源:X509CertificateHelper.cs

示例2: Load

        public static X509Certificate2 Load(StoreName name, StoreLocation location, X509FindType type, string findValue)
        {
            if (string.IsNullOrWhiteSpace(findValue))
                throw new ArgumentNullException("findValue");
            
            var store = new X509Store(name, location);
            store.Open(OpenFlags.ReadOnly);
            try
            {
                var certificates = store.Certificates.Find(type, findValue, false);

                if (certificates.Count != 1)
                {
                    throw new InvalidOperationException(
                        string.Format(CultureInfo.InvariantCulture,
                        "Finding certificate with [StoreName:{0}, StoreLocation:{1}, X509FindType: {2}, FindValue: {3}] matched {4} certificates. A unique match is required.",
                        name, location, type, findValue, certificates.Count));
                }

                return certificates[0];
            }
            finally
            {
                store.Close();
            }
        }
开发者ID:hallatore,项目名称:ITfoxtec.SAML2,代码行数:26,代码来源:CertificateUtil.cs

示例3: FromStore

 /// <summary>
 /// Will deploy certificate found by find type and find value from the local certificate store, to remote certificate store on server.
 /// </summary>
 /// <param name="findType"></param>
 /// <param name="findValue"></param>
 /// <returns></returns>
 public static IOfferRemoteConfiguration FromStore(this IOfferSslInfrastructure sslInfra, X509FindType findType, string findValue)
 {
     var infraBuilder = ((SslInfrastructureBuilder) sslInfra).InfrastructureBuilder;
     var certOp = new CertificateFromStoreOperation(findType, findValue);
     Configure.Operation(infraBuilder, certOp);
     return infraBuilder;
 }
开发者ID:peteraglen,项目名称:condep-dsl-operations,代码行数:13,代码来源:SslInfrastructureExtensions.cs

示例4: TryResolveCertificate

        internal static bool TryResolveCertificate(StoreName storeName, StoreLocation storeLocation, X509FindType findType, object findValue, out X509Certificate2 certificate)
        {
            X509Store store = new X509Store(storeName, storeLocation);
            store.Open(OpenFlags.ReadOnly);

            certificate = null;
            X509Certificate2Collection certs = null;
            X509Certificate2Collection matches = null;
            try
            {
                certs = store.Certificates;
                matches = certs.Find(findType, findValue, false);

                // Throwing InvalidOperationException here, following WCF precedent. 
                // Might be worth introducing a more specific exception here.
                if (matches.Count == 1)
                {
                    certificate = new X509Certificate2(matches[0]);
                    return true;
                }
            }
            finally
            {
                CryptoHelper.ResetAllCertificates(matches);
                CryptoHelper.ResetAllCertificates(certs);
                store.Close();
            }

            return false;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:30,代码来源:X509Util.cs

示例5: FromStore

 public IOfferInfrastructure FromStore(X509FindType findType, string findValue)
 {
     var certOp = new CertificateFromStoreOperation(findType, findValue);
     var compositeSequence = _infrastructureSequence.NewCompositeSequence(certOp);
     certOp.Configure(new RemoteCompositeBuilder(compositeSequence, _webDeploy));
     return _infrastructureBuilder;
 }
开发者ID:brigs,项目名称:ConDep,代码行数:7,代码来源:SslInfrastructureBuilder.cs

示例6: LocalMachineCertificateFactory

		/// <summary>
		/// Initializes a new instance of the <see cref="LocalMachineCertificateFactory"/> class.
		/// </summary>
		/// <param name="certificateSubject">The certificate subject.</param>
		/// <param name="findType"></param>
		public LocalMachineCertificateFactory(string certificateSubject, X509FindType findType)
		{
			_certificateSubject = certificateSubject;
			_findType = findType;

			ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;
		}
开发者ID:yonglehou,项目名称:DevDefined.OAuth,代码行数:12,代码来源:LocalMachineCertificateFactory.cs

示例7: X509SecurityTokenProvider

        public X509SecurityTokenProvider(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue)
        {
            if (findValue == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("findValue");
            }

            X509CertificateStore store = new X509CertificateStore(storeName, storeLocation);
            X509Certificate2Collection certificates = null;
            try
            {
                store.Open(OpenFlags.ReadOnly);
                certificates = store.Find(findType, findValue, false);
                if (certificates.Count < 1)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.CannotFindCert, storeName, storeLocation, findType, findValue)));
                }
                if (certificates.Count > 1)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.FoundMultipleCerts, storeName, storeLocation, findType, findValue)));
                }

                this.certificate = new X509Certificate2(certificates[0]);
            }
            finally
            {
                SecurityUtils.ResetAllCertificates(certificates);
                store.Close();
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:30,代码来源:X509SecurityTokenProvider.cs

示例8: FetchCertificate

		public FetchCertificate(X509FindType criteria, object match)
		{
			Criteria = criteria;
			MatchesValue = match;
			StoreLocation = StoreLocation.LocalMachine;
			StoreName = StoreName.My;
		}
开发者ID:janv8000,项目名称:Windsor,代码行数:7,代码来源:FetchCertificate.cs

示例9: SetCertificate

        public void SetCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue)
        {
            if (findValue == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("findValue");
            }
            ThrowIfImmutable();
            var dotNetCertificate = SecurityUtils.GetCertificateFromStore(storeName, storeLocation, findType, findValue, null);
            IReadOnlyList<Certificate> uwpCertificates;
            try
            {
                uwpCertificates = GetCertificatesFromWinRTStore(dotNetCertificate);
            }
            catch (Exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(SecurityUtils.CreateCertificateLoadException(
                    storeName, storeLocation, findType, findValue, null, 0));
            }

            if (uwpCertificates.Count != 1)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(SecurityUtils.CreateCertificateLoadException(
                    storeName, storeLocation, findType, findValue, null, uwpCertificates.Count));
            }

            AttachUwpCertificate(dotNetCertificate, uwpCertificates[0]);
            _certificate = dotNetCertificate;
        }
开发者ID:mehtavipul,项目名称:wcf,代码行数:28,代码来源:X509CertificateInitiatorClientCredential.netcore50.cs

示例10: CreateCustom

		/// <summary>
		/// Creates a custom certificate search directive, based on the specified find type and value.
		/// </summary>
		/// <param name="findType"></param>
		/// <param name="findValue"></param>
		/// <returns></returns>
		public static CertificateSearchDirective CreateCustom(X509FindType findType, string findValue)
		{
			return new CertificateSearchDirective
			{
				FindType = findType,
				FindValue = findValue
			};
		}
开发者ID:nhannd,项目名称:Xian,代码行数:14,代码来源:CertificateSearchDirective.cs

示例11: SecurityBehavior

 public SecurityBehavior(ServiceSecurity mode,StoreLocation storeLocation,StoreName storeName,X509FindType findType,string subjectName)
 {
     m_Mode = mode;
      m_StoreLocation = storeLocation;
      m_StoreName = storeName;
      m_FindType = findType;
      m_SubjectName = subjectName;
 }
开发者ID:JMnITup,项目名称:HotelApp,代码行数:8,代码来源:SecurityBehavior.cs

示例12: Find

 private IEnumerable<X509Certificate2> Find(X509FindType findType, string criteria, bool validOnly) {
     try {
         return _storeWrapper.Find(findType, criteria, validOnly);
     } finally {
         if (_storeWrapper != null) {
             _storeWrapper.Close();
         }
     }
 }
开发者ID:amido,项目名称:CertificateRepository,代码行数:9,代码来源:CertificateRepository.cs

示例13: SetCertificate

 public void SetCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue)
 {
     if (findValue == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("findValue");
     }
     ThrowIfImmutable();
     _certificate = SecurityUtils.GetCertificateFromStore(storeName, storeLocation, findType, findValue, null);
 }
开发者ID:mehtavipul,项目名称:wcf,代码行数:9,代码来源:X509CertificateInitiatorClientCredential.CoreCLR.cs

示例14: ConfigureAnonymousMessageSecurity

        public void ConfigureAnonymousMessageSecurity(StoreLocation location,StoreName storeName,X509FindType findType,object findValue)
        {
            Credentials.ServiceCertificate.SetCertificate(location,storeName,findType,findValue);
             Authorization.PrincipalPermissionMode = PrincipalPermissionMode.None;

             foreach(ServiceEndpoint endpoint in Description.Endpoints)
             {
            ServiceBusHelper.ConfigureBinding(endpoint.Binding);
             }
        }
开发者ID:JMnITup,项目名称:SMEX,代码行数:10,代码来源:ServiceBusHost.cs

示例15: SetCertificate

		public void SetCertificate (StoreLocation storeLocation,
			StoreName storeName, X509FindType findType,
			object findValue)
		{
#if !MOBILE
			certificate = ConfigUtil.CreateCertificateFrom (storeLocation, storeName, findType, findValue);
#else
			throw new NotImplementedException ();
#endif
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:10,代码来源:X509CertificateInitiatorClientCredential.cs


注:本文中的X509FindType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。