SslStream Constructores

Definición

Inicializa una nueva instancia de la clase SslStream.Initializes a new instance of the SslStream class.

Sobrecargas

SslStream(Stream)

Inicializa una nueva instancia de la clase SslStream utilizando la clase Stream especificada.Initializes a new instance of the SslStream class using the specified Stream.

SslStream(Stream, Boolean)

Inicializa una nueva instancia de la clase SslStream utilizando el objeto Stream especificado y el comportamiento de cierre de secuencias.Initializes a new instance of the SslStream class using the specified Stream and stream closure behavior.

SslStream(Stream, Boolean, RemoteCertificateValidationCallback)

Inicializa una nueva instancia de la clase SslStream utilizando el objeto Stream, el comportamiento de cierre de secuencias y el delegado de validación de certificados especificados.Initializes a new instance of the SslStream class using the specified Stream, stream closure behavior and certificate validation delegate.

SslStream(Stream, Boolean, RemoteCertificateValidationCallback, LocalCertificateSelectionCallback)

Inicializa una nueva instancia de la clase SslStream utilizando el objeto Stream, el delegado de validación de certificados y el delegado de selección de certificados especificados.Initializes a new instance of the SslStream class using the specified Stream, stream closure behavior, certificate validation delegate and certificate selection delegate.

SslStream(Stream, Boolean, RemoteCertificateValidationCallback, LocalCertificateSelectionCallback, EncryptionPolicy)

Inicializa una nueva instancia de la clase SslStream usando el objeto Stream especificado.Initializes a new instance of the SslStream class using the specified Stream

Comentarios

Para evitar que el SslStream cierre de la secuencia proporcionada, use el SslStream constructor.To prevent the SslStream from closing the stream that you supply, use the SslStream constructor.

SslStream(Stream)

Inicializa una nueva instancia de la clase SslStream utilizando la clase Stream especificada.Initializes a new instance of the SslStream class using the specified Stream.

public:
 SslStream(System::IO::Stream ^ innerStream);
public SslStream (System.IO.Stream innerStream);
new System.Net.Security.SslStream : System.IO.Stream -> System.Net.Security.SslStream
Public Sub New (innerStream As Stream)

Parámetros

innerStream
Stream

Objeto Stream que la clase SslStream utiliza para enviar y recibir datos.A Stream object used by the SslStream for sending and receiving data.

Excepciones

No se puede leer en innerStream.innerStream is not readable.

O bien-or- No se puede escribir en innerStream.innerStream is not writable.

innerStream es null.innerStream is null.

O bien-or- innerStream es igual a Null.innerStream is equal to Null.

Comentarios

Si no se especifica un valor en el archivo de configuración de EncryptionPolicy, el EncryptionPolicy valor predeterminado es EncryptionPolicy.RequireEncryption para la SslStream instancia que se construye.If a value is not specified in the configuration file for encryptionpolicy, the EncryptionPolicy defaults to EncryptionPolicy.RequireEncryption for the SslStream instance that is constructed.

El uso del cifrado NULL es necesario cuando la Directiva de cifrado se establece en EncryptionPolicy.NoEncryption .The use of the Null cipher is required when the encryption policy is set to EncryptionPolicy.NoEncryption.

Se aplica a

SslStream(Stream, Boolean)

Inicializa una nueva instancia de la clase SslStream utilizando el objeto Stream especificado y el comportamiento de cierre de secuencias.Initializes a new instance of the SslStream class using the specified Stream and stream closure behavior.

public:
 SslStream(System::IO::Stream ^ innerStream, bool leaveInnerStreamOpen);
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen);
new System.Net.Security.SslStream : System.IO.Stream * bool -> System.Net.Security.SslStream
Public Sub New (innerStream As Stream, leaveInnerStreamOpen As Boolean)

Parámetros

innerStream
Stream

Objeto Stream que la clase SslStream utiliza para enviar y recibir datos.A Stream object used by the SslStream for sending and receiving data.

leaveInnerStreamOpen
Boolean

Valor booleano que indica el comportamiento de cierre del objeto Stream usado por SslStream para enviar y recibir datos.A Boolean value that indicates the closure behavior of the Stream object used by the SslStream for sending and receiving data. Este parámetro indica si se ha dejado abierta la secuencia interna.This parameter indicates if the inner stream is left open.

Excepciones

No se puede leer en innerStream.innerStream is not readable.

O bien-or- No se puede escribir en innerStream.innerStream is not writable.

innerStream es null.innerStream is null.

O bien-or- innerStream es igual a Null.innerStream is equal to Null.

Ejemplos

En el ejemplo de código siguiente se muestra cómo llamar a este constructor.The following code example demonstrates calling this constructor.

static void ProcessClient( TcpClient^ client )
{
   
   // A client has connected. Create the 
   // SslStream using the client's network stream.
   SslStream^ sslStream = gcnew SslStream( client->GetStream(),false );
   
   // Authenticate the server but don't require the client to authenticate.
   try
   {
      sslStream->AuthenticateAsServer( serverCertificate, false, true );
      // false == no client cert required; true == check cert revocation.
      
      // Display the properties and settings for the authenticated stream.
      DisplaySecurityLevel( sslStream );
      DisplaySecurityServices( sslStream );
      DisplayCertificateInformation( sslStream );
      DisplayStreamProperties( sslStream );
      
      // Set timeouts for the read and write to 5 seconds.
      sslStream->ReadTimeout = 5000;
      sslStream->WriteTimeout = 5000;
      
      // Read a message from the client.   
      Console::WriteLine( L"Waiting for client message..." );
      String^ messageData = ReadMessage( sslStream );
      Console::WriteLine( L"Received: {0}", messageData );
      
      // Write a message to the client.
      array<Byte>^message = Encoding::UTF8->GetBytes( L"Hello from the server.<EOF>" );
      Console::WriteLine( L"Sending hello message." );
      sslStream->Write( message );
   }
   catch ( AuthenticationException^ e ) 
   {
      Console::WriteLine( L"Exception: {0}", e->Message );
      if ( e->InnerException != nullptr )
      {
         Console::WriteLine( L"Inner exception: {0}", e->InnerException->Message );
      }
      Console::WriteLine( L"Authentication failed - closing the connection." );
      sslStream->Close();
      client->Close();
      return;
   }
   finally
   {
      
      // The client stream will be closed with the sslStream
      // because we specified this behavior when creating
      // the sslStream.
      sslStream->Close();
      client->Close();
   }

}


static void ProcessClient (TcpClient client)
{
    // A client has connected. Create the
    // SslStream using the client's network stream.
    SslStream sslStream = new SslStream(
        client.GetStream(), false);
    // Authenticate the server but don't require the client to authenticate.
    try
    {
        sslStream.AuthenticateAsServer(serverCertificate, clientCertificateRequired: false, checkCertificateRevocation: true);

        // Display the properties and settings for the authenticated stream.
        DisplaySecurityLevel(sslStream);
        DisplaySecurityServices(sslStream);
        DisplayCertificateInformation(sslStream);
        DisplayStreamProperties(sslStream);

        // Set timeouts for the read and write to 5 seconds.
        sslStream.ReadTimeout = 5000;
        sslStream.WriteTimeout = 5000;
        // Read a message from the client.
        Console.WriteLine("Waiting for client message...");
        string messageData = ReadMessage(sslStream);
        Console.WriteLine("Received: {0}", messageData);

        // Write a message to the client.
        byte[] message = Encoding.UTF8.GetBytes("Hello from the server.<EOF>");
        Console.WriteLine("Sending hello message.");
        sslStream.Write(message);
    }
    catch (AuthenticationException e)
    {
        Console.WriteLine("Exception: {0}", e.Message);
        if (e.InnerException != null)
        {
            Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
        }
        Console.WriteLine ("Authentication failed - closing the connection.");
        sslStream.Close();
        client.Close();
        return;
    }
    finally
    {
        // The client stream will be closed with the sslStream
        // because we specified this behavior when creating
        // the sslStream.
        sslStream.Close();
        client.Close();
    }
}
Private Shared Sub ProcessClient(client As TcpClient)
    ' A client has connected. Create the 
    ' SslStream using the client's network stream.
    Dim sslStream = New SslStream(client.GetStream(), False)

    Try

        sslStream.AuthenticateAsServer(serverCertificate, clientCertificateRequired:=False, checkCertificateRevocation:=True)
        ' Display the properties And settings for the authenticated stream.
        DisplaySecurityLevel(sslStream)
        DisplaySecurityServices(sslStream)
        DisplayCertificateInformation(sslStream)
        DisplayStreamProperties(sslStream)

        ' Set timeouts for the read and write to 5 seconds.
        sslStream.ReadTimeout = 5000
        sslStream.WriteTimeout = 5000

        ' Read a message from the client.   
        Console.WriteLine("Waiting for client message...")
        Dim messageData As String = ReadMessage(sslStream)
        Console.WriteLine("Received: {0}", messageData)

        ' Write a message to the client.
        Dim message As Byte() = Encoding.UTF8.GetBytes("Hello from the server.<EOF>")
        Console.WriteLine("Sending hello message.")
        sslStream.Write(message)
    Catch e As AuthenticationException
        Console.WriteLine("Exception: {0}", e.Message)

        If e.InnerException IsNot Nothing Then
            Console.WriteLine("Inner exception: {0}", e.InnerException.Message)
        End If

        Console.WriteLine("Authentication failed - closing the connection.")
        sslStream.Close()
        client.Close()
        Return
    Finally
        ' The client stream will be closed with the sslStream
        ' because we specified this behavior when creating
        ' the sslStream.
        sslStream.Close()
        client.Close()
    End Try
End Sub

Comentarios

Cuando se especifica true para el leaveStreamOpen parámetro, el cierre de SslStream no tiene ningún efecto en el innerStream flujo; debe cerrarse explícitamente innerStream cuando ya no lo necesite.When you specify true for the leaveStreamOpen parameter, closing the SslStream has no effect on the innerStream stream; you must explicitly close innerStream when you no longer need it.

Si no se especifica un valor en el archivo de configuración de EncryptionPolicy, el EncryptionPolicy valor predeterminado es EncryptionPolicy.RequireEncryption para la SslStream instancia que se construye.If a value is not specified in the configuration file for encryptionpolicy, the EncryptionPolicy defaults to EncryptionPolicy.RequireEncryption for the SslStream instance that is constructed.

El uso del cifrado NULL es necesario cuando la Directiva de cifrado se establece en EncryptionPolicy.NoEncryption .The use of the Null cipher is required when the encryption policy is set to EncryptionPolicy.NoEncryption.

Se aplica a

SslStream(Stream, Boolean, RemoteCertificateValidationCallback)

Inicializa una nueva instancia de la clase SslStream utilizando el objeto Stream, el comportamiento de cierre de secuencias y el delegado de validación de certificados especificados.Initializes a new instance of the SslStream class using the specified Stream, stream closure behavior and certificate validation delegate.

public:
 SslStream(System::IO::Stream ^ innerStream, bool leaveInnerStreamOpen, System::Net::Security::RemoteCertificateValidationCallback ^ userCertificateValidationCallback);
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen, System.Net.Security.RemoteCertificateValidationCallback? userCertificateValidationCallback);
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen, System.Net.Security.RemoteCertificateValidationCallback userCertificateValidationCallback);
new System.Net.Security.SslStream : System.IO.Stream * bool * System.Net.Security.RemoteCertificateValidationCallback -> System.Net.Security.SslStream
Public Sub New (innerStream As Stream, leaveInnerStreamOpen As Boolean, userCertificateValidationCallback As RemoteCertificateValidationCallback)

Parámetros

innerStream
Stream

Objeto Stream que la clase SslStream utiliza para enviar y recibir datos.A Stream object used by the SslStream for sending and receiving data.

leaveInnerStreamOpen
Boolean

Valor booleano que indica el comportamiento de cierre del objeto Stream usado por SslStream para enviar y recibir datos.A Boolean value that indicates the closure behavior of the Stream object used by the SslStream for sending and receiving data. Este parámetro indica si se ha dejado abierta la secuencia interna.This parameter indicates if the inner stream is left open.

userCertificateValidationCallback
RemoteCertificateValidationCallback

Delegado de RemoteCertificateValidationCallback responsable de la validación del certificado proporcionado por la parte remota.A RemoteCertificateValidationCallback delegate responsible for validating the certificate supplied by the remote party.

Excepciones

No se puede leer en innerStream.innerStream is not readable.

O bien-or- No se puede escribir en innerStream.innerStream is not writable.

innerStream es null.innerStream is null.

O bien-or- innerStream es igual a Null.innerStream is equal to Null.

Ejemplos

En el ejemplo de código siguiente se crea un SslStream e inicia la parte del cliente de la autenticación.The following code example creates an SslStream and initiates the client portion of the authentication.

// Create a TCP/IP client socket.
// machineName is the host running the server application.
TcpClient^ client = gcnew TcpClient(machineName, 8080);
Console::WriteLine("Client connected.");
  
// Create an SSL stream that will close 
// the client's stream.
SslStream^ sslStream = gcnew SslStream(
    client->GetStream(), false,
    gcnew RemoteCertificateValidationCallback(ValidateServerCertificate),
    nullptr);
  
// The server name must match the name
// on the server certificate.
try
{
    sslStream->AuthenticateAsClient(serverName);
}
catch (AuthenticationException^ ex) 
{
    Console::WriteLine("Exception: {0}", ex->Message);
    if (ex->InnerException != nullptr)
    {
        Console::WriteLine("Inner exception: {0}", 
            ex->InnerException->Message);
    }

    Console::WriteLine("Authentication failed - "
        "closing the connection.");
    sslStream->Close();
    client->Close();
    return;
}
// Create a TCP/IP client socket.
// machineName is the host running the server application.
TcpClient client = new TcpClient(machineName,443);
Console.WriteLine("Client connected.");
// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
    client.GetStream(),
    false,
    new RemoteCertificateValidationCallback (ValidateServerCertificate),
    null
    );
// The server name must match the name on the server certificate.
try
{
    sslStream.AuthenticateAsClient(serverName);
}
catch (AuthenticationException e)
{
    Console.WriteLine("Exception: {0}", e.Message);
    if (e.InnerException != null)
    {
        Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
    }
    Console.WriteLine ("Authentication failed - closing the connection.");
    client.Close();
    return;
}
' Create a TCP/IP client socket.
' machineName is the host running the server application.
Dim client = New TcpClient(machineName, 443)
Console.WriteLine("Client connected.")

' Create an SSL stream that will close the client's stream.
Dim sslStream = New SslStream(
    client.GetStream(), False, 
    New RemoteCertificateValidationCallback(AddressOf ValidateServerCertificate), Nothing)

' The server name must match the name on the server certificate.
Try
    sslStream.AuthenticateAsClient(serverName)
Catch e As AuthenticationException
    Console.WriteLine("Exception: {0}", e.Message)

    If e.InnerException IsNot Nothing Then
        Console.WriteLine("Inner exception: {0}", e.InnerException.Message)
    End If

    Console.WriteLine("Authentication failed - closing the connection.")
    client.Close()
    Return
End Try

Comentarios

Cuando se especifica true para el leaveStreamOpen parámetro, el cierre de SslStream no tiene ningún efecto en el innerStream flujo; debe cerrarse explícitamente innerStream cuando ya no lo necesite.When you specify true for the leaveStreamOpen parameter, closing the SslStream has no effect on the innerStream stream; you must explicitly close innerStream when you no longer need it.

El userCertificateValidationCallback argumento del delegado certificateErrors contiene los códigos de error de Windows devueltos por la interfaz del proveedor de compatibilidad para seguridad (SSPI) del canal.The userCertificateValidationCallback delegate's certificateErrors argument contains any Windows error codes returned by the channel Security Support Provider Interface (SSPI). El valor devuelto del método invocado por el userCertificateValidationCallback delegado determina si la autenticación se realiza correctamente.The return value of the method invoked by the userCertificateValidationCallback delegate determines whether authentication succeeds.

El protocolo de seguridad y los algoritmos criptográficos ya están seleccionados cuando userCertificateValidationCallback se invoca el método del delegado.The security protocol and cryptographic algorithms are already selected when the userCertificateValidationCallback delegate's method is invoked. Puede usar el método para determinar si los algoritmos criptográficos y los niveles de solidez seleccionados son suficientes para la aplicación.You can use the method to determine whether the selected cryptographic algorithms and strengths are sufficient for your application. De lo contrario, el método debe devolver false para evitar que SslStream se cree.If not, the method should return false to prevent the SslStream from being created.

Si no se especifica un valor en el archivo de configuración de EncryptionPolicy, el EncryptionPolicy valor predeterminado es EncryptionPolicy.RequireEncryption para la SslStream instancia que se construye.If a value is not specified in the configuration file for encryptionpolicy, the EncryptionPolicy defaults to EncryptionPolicy.RequireEncryption for the SslStream instance that is constructed.

El uso del cifrado NULL es necesario cuando la Directiva de cifrado se establece en EncryptionPolicy.NoEncryption .The use of the Null cipher is required when the encryption policy is set to EncryptionPolicy.NoEncryption.

Nota

El marco de trabajo almacena en caché las sesiones SSL a medida que se crean e intenta volver a usar una sesión almacenada en caché para una nueva solicitud, si es posible.The Framework caches SSL sessions as they are created and attempts to reuse a cached session for a new request, if possible. Al intentar volver a usar una sesión de SSL, el marco de trabajo usa el primer elemento de ClientCertificates (si hay alguno) o intenta reutilizar las sesiones anónimas si ClientCertificates está vacía.When attempting to reuse an SSL session, the Framework uses the first element of ClientCertificates (if there is one), or tries to reuse an anonymous sessions if ClientCertificates is empty.

Nota

Los certificados de cliente no se admiten en el protocolo SSL versión 2.Client certificates are not supported in the SSL version 2 protocol.

Se aplica a

SslStream(Stream, Boolean, RemoteCertificateValidationCallback, LocalCertificateSelectionCallback)

Inicializa una nueva instancia de la clase SslStream utilizando el objeto Stream, el delegado de validación de certificados y el delegado de selección de certificados especificados.Initializes a new instance of the SslStream class using the specified Stream, stream closure behavior, certificate validation delegate and certificate selection delegate.

public:
 SslStream(System::IO::Stream ^ innerStream, bool leaveInnerStreamOpen, System::Net::Security::RemoteCertificateValidationCallback ^ userCertificateValidationCallback, System::Net::Security::LocalCertificateSelectionCallback ^ userCertificateSelectionCallback);
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen, System.Net.Security.RemoteCertificateValidationCallback? userCertificateValidationCallback, System.Net.Security.LocalCertificateSelectionCallback? userCertificateSelectionCallback);
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen, System.Net.Security.RemoteCertificateValidationCallback userCertificateValidationCallback, System.Net.Security.LocalCertificateSelectionCallback userCertificateSelectionCallback);
new System.Net.Security.SslStream : System.IO.Stream * bool * System.Net.Security.RemoteCertificateValidationCallback * System.Net.Security.LocalCertificateSelectionCallback -> System.Net.Security.SslStream
Public Sub New (innerStream As Stream, leaveInnerStreamOpen As Boolean, userCertificateValidationCallback As RemoteCertificateValidationCallback, userCertificateSelectionCallback As LocalCertificateSelectionCallback)

Parámetros

innerStream
Stream

Objeto Stream que la clase SslStream utiliza para enviar y recibir datos.A Stream object used by the SslStream for sending and receiving data.

leaveInnerStreamOpen
Boolean

Valor booleano que indica el comportamiento de cierre del objeto Stream usado por SslStream para enviar y recibir datos.A Boolean value that indicates the closure behavior of the Stream object used by the SslStream for sending and receiving data. Este parámetro indica si se ha dejado abierta la secuencia interna.This parameter indicates if the inner stream is left open.

userCertificateValidationCallback
RemoteCertificateValidationCallback

Delegado de RemoteCertificateValidationCallback responsable de la validación del certificado proporcionado por la parte remota.A RemoteCertificateValidationCallback delegate responsible for validating the certificate supplied by the remote party.

userCertificateSelectionCallback
LocalCertificateSelectionCallback

Delegado de LocalCertificateSelectionCallback responsable de seleccionar el certificado utilizado para la autenticación.A LocalCertificateSelectionCallback delegate responsible for selecting the certificate used for authentication.

Excepciones

No se puede leer en innerStream.innerStream is not readable.

O bien-or- No se puede escribir en innerStream.innerStream is not writable.

innerStream es null.innerStream is null.

O bien-or- innerStream es igual a Null.innerStream is equal to Null.

Ejemplos

En el ejemplo de código siguiente se muestra cómo llamar a este constructor.The following code example demonstrates calling this constructor. Este ejemplo forma parte de un ejemplo más extenso proporcionado para la SslStream clase.This example is part of a larger example provided for the SslStream class.

// Server name must match the host name and the name on the host's certificate. 
serverName = args[ 1 ];

// Create a TCP/IP client socket.
TcpClient^ client = gcnew TcpClient( serverName,80 );
Console::WriteLine( L"Client connected." );

// Create an SSL stream that will close the client's stream.
SslStream^ sslStream = gcnew SslStream( 
    client->GetStream(),
    false,
    gcnew RemoteCertificateValidationCallback( ValidateServerCertificate ),
    gcnew LocalCertificateSelectionCallback( SelectLocalCertificate ) );

// Server name must match the host name and the name on the host's certificate.
serverName = args[0];
// Create a TCP/IP client socket.
TcpClient client = new TcpClient(serverName,80);
Console.WriteLine("Client connected.");
// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
    client.GetStream(),
    false,
    new RemoteCertificateValidationCallback (ValidateServerCertificate),
    new LocalCertificateSelectionCallback(SelectLocalCertificate)
    );
' Server name must match the host name and the name on the host's certificate. 
serverName = args(0)
' Create a TCP/IP client socket.
Dim client As New TcpClient(serverName, 80)
Console.WriteLine("Client connected.")
' Create an SSL stream that will close the client's stream.
Dim sslStream As New SslStream(
    client.GetStream(), False, 
    New RemoteCertificateValidationCallback(AddressOf ValidateServerCertificate), 
    New LocalCertificateSelectionCallback(AddressOf SelectLocalCertificate))

Comentarios

Cuando se especifica true para el leaveStreamOpen parámetro, el cierre de SslStream no tiene ningún efecto en el innerStream flujo; debe cerrarse explícitamente innerStream cuando ya no lo necesite.When you specify true for the leaveStreamOpen parameter, closing the SslStream has no effect on the innerStream stream; you must explicitly close innerStream when you no longer need it.

El userCertificateValidationCallback argumento del delegado certificateErrors contiene los códigos de error de Windows devueltos por la interfaz del proveedor de compatibilidad para seguridad (SSPI) del canal.The userCertificateValidationCallback delegate's certificateErrors argument contains any Windows error codes returned by the channel Security Support Provider Interface (SSPI). El valor devuelto del método invocado por el userCertificateValidationCallback delegado determina si la autenticación se realiza correctamente.The return value of the method invoked by the userCertificateValidationCallback delegate determines whether authentication succeeds.

El protocolo de seguridad y los algoritmos criptográficos ya están seleccionados cuando userCertificateValidationCallback se invoca el método del delegado.The security protocol and cryptographic algorithms are already selected when the userCertificateValidationCallback delegate's method is invoked. Puede usar el método para determinar si los algoritmos criptográficos y los niveles de solidez seleccionados son suficientes para la aplicación.You can use the method to determine whether the selected cryptographic algorithms and strengths are sufficient for your application. De lo contrario, el método debe devolver false para evitar que SslStream se cree.If not, the method should return false to prevent the SslStream from being created.

El userCertificateSelectionCallback delegado es útil cuando la aplicación tiene varios certificados y debe elegir de forma dinámica un certificado.The userCertificateSelectionCallback delegate is useful when your application has multiple certificates and must dynamically choose a certificate. Los certificados del almacén "MY" se pasan al método invocado por el delegado.Certificates in the "MY" store are passed to the method invoked by the delegate.

Si no se especifica un valor en el archivo de configuración de EncryptionPolicy, el EncryptionPolicy valor predeterminado es EncryptionPolicy.RequireEncryption para la SslStream instancia que se construye.If a value is not specified in the configuration file for encryptionpolicy, the EncryptionPolicy defaults to EncryptionPolicy.RequireEncryption for the SslStream instance that is constructed.

El uso del cifrado NULL es necesario cuando la Directiva de cifrado se establece en EncryptionPolicy.NoEncryption .The use of the Null cipher is required when the encryption policy is set to EncryptionPolicy.NoEncryption.

Nota

El marco de trabajo almacena en caché las sesiones SSL a medida que se crean e intenta volver a usar una sesión almacenada en caché para una nueva solicitud, si es posible.The Framework caches SSL sessions as they are created and attempts to reuse a cached session for a new request, if possible. Al intentar volver a usar una sesión de SSL, el marco de trabajo usa el primer elemento de P:System.Net.HttpWebRequest.ClientCertificates (si hay alguno) o intenta reutilizar las sesiones anónimas si P:System.Net.HttpWebRequest.ClientCertificates está vacío.When attempting to reuse an SSL session, the Framework uses the first element of P:System.Net.HttpWebRequest.ClientCertificates (if there is one), or tries to reuse an anonymous sessions if P:System.Net.HttpWebRequest.ClientCertificates is empty.

Se aplica a

SslStream(Stream, Boolean, RemoteCertificateValidationCallback, LocalCertificateSelectionCallback, EncryptionPolicy)

Inicializa una nueva instancia de la clase SslStream usando el objeto Stream especificado.Initializes a new instance of the SslStream class using the specified Stream

public:
 SslStream(System::IO::Stream ^ innerStream, bool leaveInnerStreamOpen, System::Net::Security::RemoteCertificateValidationCallback ^ userCertificateValidationCallback, System::Net::Security::LocalCertificateSelectionCallback ^ userCertificateSelectionCallback, System::Net::Security::EncryptionPolicy encryptionPolicy);
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen, System.Net.Security.RemoteCertificateValidationCallback? userCertificateValidationCallback, System.Net.Security.LocalCertificateSelectionCallback? userCertificateSelectionCallback, System.Net.Security.EncryptionPolicy encryptionPolicy);
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen, System.Net.Security.RemoteCertificateValidationCallback userCertificateValidationCallback, System.Net.Security.LocalCertificateSelectionCallback userCertificateSelectionCallback, System.Net.Security.EncryptionPolicy encryptionPolicy);
[System.MonoLimitation("encryptionPolicy is ignored")]
public SslStream (System.IO.Stream innerStream, bool leaveInnerStreamOpen, System.Net.Security.RemoteCertificateValidationCallback userCertificateValidationCallback, System.Net.Security.LocalCertificateSelectionCallback userCertificateSelectionCallback, System.Net.Security.EncryptionPolicy encryptionPolicy);
new System.Net.Security.SslStream : System.IO.Stream * bool * System.Net.Security.RemoteCertificateValidationCallback * System.Net.Security.LocalCertificateSelectionCallback * System.Net.Security.EncryptionPolicy -> System.Net.Security.SslStream
[<System.MonoLimitation("encryptionPolicy is ignored")>]
new System.Net.Security.SslStream : System.IO.Stream * bool * System.Net.Security.RemoteCertificateValidationCallback * System.Net.Security.LocalCertificateSelectionCallback * System.Net.Security.EncryptionPolicy -> System.Net.Security.SslStream
Public Sub New (innerStream As Stream, leaveInnerStreamOpen As Boolean, userCertificateValidationCallback As RemoteCertificateValidationCallback, userCertificateSelectionCallback As LocalCertificateSelectionCallback, encryptionPolicy As EncryptionPolicy)

Parámetros

innerStream
Stream

Objeto Stream que la clase SslStream utiliza para enviar y recibir datos.A Stream object used by the SslStream for sending and receiving data.

leaveInnerStreamOpen
Boolean

Valor booleano que indica el comportamiento de cierre del objeto Stream usado por SslStream para enviar y recibir datos.A Boolean value that indicates the closure behavior of the Stream object used by the SslStream for sending and receiving data. Este parámetro indica si se ha dejado abierta la secuencia interna.This parameter indicates if the inner stream is left open.

userCertificateValidationCallback
RemoteCertificateValidationCallback

Delegado de RemoteCertificateValidationCallback responsable de la validación del certificado proporcionado por la parte remota.A RemoteCertificateValidationCallback delegate responsible for validating the certificate supplied by the remote party.

userCertificateSelectionCallback
LocalCertificateSelectionCallback

Delegado de LocalCertificateSelectionCallback responsable de seleccionar el certificado utilizado para la autenticación.A LocalCertificateSelectionCallback delegate responsible for selecting the certificate used for authentication.

encryptionPolicy
EncryptionPolicy

Objeto EncryptionPolicy que se va a usar.The EncryptionPolicy to use.

Atributos
MonoLimitationAttribute

Excepciones

No se puede leer en innerStream.innerStream is not readable.

O bien-or- No se puede escribir en innerStream.innerStream is not writable.

O bien-or- encryptionPolicy no es válido.encryptionPolicy is not valid.

innerStream es null.innerStream is null.

O bien-or- innerStream es igual a Null.innerStream is equal to Null.

Comentarios

El uso del cifrado NULL es necesario cuando el encryptionPolicy parámetro se establece en EncryptionPolicy.NoEncryption .The use of the Null cipher is required when the encryptionPolicy parameter is set to EncryptionPolicy.NoEncryption.

Se aplica a