Represents a collection of SSL stream provider objects. This class is used internally by the .NET Framework to manage providers that can be used to create and configure SSL streams.
It is generally not necessary to interact with this class directly. The .NET Framework handles its management as part of establishing secure network connections.
public sealed class SslStreamProviderCollection : IEnumerable
Namespace: System.Net.Security
Assembly: System (in System.dll)
The SslStreamProviderCollection class has the following members:
Gets the SslStreamProvider object at the specified index.
index: The zero-based index of the SslStreamProvider object to retrieve.
Returns: An SslStreamProvider object.
Adds an SslStreamProvider object to the collection.
provider: The SslStreamProvider to add.
Returns: void
Removes all SslStreamProvider objects from the collection.
Returns: void
Determines whether the collection contains the specified SslStreamProvider object.
provider: The SslStreamProvider to locate in the collection.
Returns: true if the provider is found; otherwise, false.
Copies the SslStreamProvider objects in the collection to a one-dimensional array, starting at the specified index.
array: The one-dimensional SslStreamProvider array that is the destination of the elements copied from the collection. The array must have zero-based indexing.
arrayIndex: The zero-based index in array at which the copying begins.
Returns: void
Returns an enumerator that iterates through the collection.
Returns: An IEnumerator object that can be used to iterate through the collection.
Removes the first occurrence of the specified SslStreamProvider object from the collection.
provider: The SslStreamProvider to remove.
Returns: true if the provider was successfully removed; otherwise, false.
The following C# code demonstrates how to use the SslStreamProviderCollection, although it's typically managed internally by the .NET runtime. This example is for illustrative purposes:
using System;
using System.Net.Security;
public class Example
{
public static void Main(string[] args)
{
// Note: This class is primarily for internal use.
// Direct manipulation is uncommon in typical application code.
// Imagine obtaining a collection instance from the framework
// SslStreamProviderCollection providerCollection = GetInternalProviderCollection();
// This is a conceptual example.
Console.WriteLine("SslStreamProviderCollection is typically managed internally.");
// Example of checking if a provider exists (hypothetical)
// SslStreamProvider someProvider = new MyCustomSslProvider(); // Assume this exists
// if (providerCollection.Contains(someProvider))
// {
// Console.WriteLine("Custom provider is in the collection.");
// }
}
// Hypothetical method to illustrate internal management
// private static SslStreamProviderCollection GetInternalProviderCollection()
// {
// // In a real scenario, this would be provided by the .NET runtime.
// return new SslStreamProviderCollection();
// }
}
// Dummy class to represent a provider for illustration
public class MyCustomSslProvider : SslStreamProvider
{
public override void SetCertificate(System.Security.Cryptography.X509Certificates.X509Certificate certificate)
{
throw new NotImplementedException();
}
public override void SetRemoteCertificate(System.Security.Cryptography.X509Certificates.X509Certificate certificate)
{
throw new NotImplementedException();
}
public override void ValidateRemoteCertificate(System.Security.Cryptography.X509Certificates.X509Certificate certificate, string targetHost, System.Security.Cryptography.OidCollection acceptedOids)
{
throw new NotImplementedException();
}
}