다음을 통해 공유


NegotiateStream 클래스

정의

클라이언트-서버 통신에서 클라이언트 및 선택적으로 서버를 인증하기 위해 협상 보안 프로토콜을 사용하는 스트림을 제공합니다.

public ref class NegotiateStream : System::Net::Security::AuthenticatedStream
public class NegotiateStream : System.Net.Security.AuthenticatedStream
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public class NegotiateStream : System.Net.Security.AuthenticatedStream
type NegotiateStream = class
    inherit AuthenticatedStream
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
type NegotiateStream = class
    inherit AuthenticatedStream
Public Class NegotiateStream
Inherits AuthenticatedStream
상속
상속
특성

예제

다음 예제에서는 NegotiateStream사용하는 클라이언트-서버 연결의 클라이언트 쪽을 보여 줍니다. 클라이언트는 인증을 받고 메시지를 비동기적으로 서버에 보냅니다.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::Security;
using namespace System::Net::Sockets;
using namespace System::Text;

// The following class displays the properties of an authenticatedStream.
public ref class AuthenticatedStreamReporter
{
public:
   static void DisplayProperties( AuthenticatedStream^ stream )
   {
      Console::WriteLine( L"IsAuthenticated: {0}", stream->IsAuthenticated );
      Console::WriteLine( L"IsMutuallyAuthenticated: {0}", stream->IsMutuallyAuthenticated );
      Console::WriteLine( L"IsEncrypted: {0}", stream->IsEncrypted );
      Console::WriteLine( L"IsSigned: {0}", stream->IsSigned );
      Console::WriteLine( L"IsServer: {0}", stream->IsServer );
   }

};


public ref class ASynchronousAuthenticatingTcpClient
{
private:
   static TcpClient^ client = nullptr;

public:
   void Main()
   {
      
      // Establish the remote endpoint for the socket.
      // For this example, use the local machine.
      IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() );
      IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ];
      
      // Client and server use port 11000. 
      IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 );
      
      // Create a TCP/IP socket.
      client = gcnew TcpClient;
      
      // Connect the socket to the remote endpoint.
      client->Connect( remoteEP );
      Console::WriteLine( L"Client connected to {0}.", remoteEP );
      
      // Ensure the client does not close when there is 
      // still data to be sent to the server.
      client->LingerState = (gcnew LingerOption( true,0 ));
      
      // Request authentication.
      NetworkStream^ clientStream = client->GetStream();
      NegotiateStream^ authStream = gcnew NegotiateStream( clientStream,false );
      
      // Pass the NegotiateStream as the AsyncState object 
      // so that it is available to the callback delegate.
      IAsyncResult^ ar = authStream->BeginAuthenticateAsClient( gcnew AsyncCallback( EndAuthenticateCallback ), authStream );
      
      Console::WriteLine( L"Client waiting for authentication..." );
      
      // Wait until the result is available.
      ar->AsyncWaitHandle->WaitOne();
      
      // Display the properties of the authenticated stream.
      AuthenticatedStreamReporter::DisplayProperties( authStream );
      
      // Send a message to the server.
      // Encode the test data into a byte array.
      array<Byte>^message = Encoding::UTF8->GetBytes( L"Hello from the client." );
      ar = authStream->BeginWrite( message, 0, message->Length, gcnew AsyncCallback( EndWriteCallback ), authStream );
      
      ar->AsyncWaitHandle->WaitOne();
      Console::WriteLine( L"Sent {0} bytes.", message->Length );
      
      // Close the client connection.
      authStream->Close();
      Console::WriteLine( L"Client closed." );
   }


   // The following method is called when the authentication completes.
   static void EndAuthenticateCallback( IAsyncResult^ ar )
   {
      Console::WriteLine( L"Client ending authentication..." );
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(ar->AsyncState);
      
      // End the asynchronous operation.
      authStream->EndAuthenticateAsClient( ar );
      
      //         Console.WriteLine("AllowedImpersonation: {0}", authStream.AllowedImpersonation);
   }


   // The following method is called when the write operation completes.
   static void EndWriteCallback( IAsyncResult^ ar )
   {
      Console::WriteLine( L"Client ending write operation..." );
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(ar->AsyncState);
      
      // End the asynchronous operation.
      authStream->EndWrite( ar );
   }

};

void main()
{
   ASynchronousAuthenticatingTcpClient^ aatc = gcnew ASynchronousAuthenticatingTcpClient;
   aatc->Main();
}
using System;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Text;

namespace Examples.NegotiateStreamExample
{
    public class ASynchronousAuthenticatingTcpClient
    {
        static TcpClient client = null;

        public static void Main(String[] args)
        {
            // Establish the remote endpoint for the socket.
            // For this example, use the local machine.
            IPHostEntry ipHostInfo = Dns.GetHostEntry("localhost");
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            // Client and server use port 11000.
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
            // Create a TCP/IP socket.
            client = new TcpClient();
            // Connect the socket to the remote endpoint.
            client.Connect(remoteEP);
            Console.WriteLine("Client connected to {0}.", remoteEP.ToString());
            // Ensure the client does not close when there is
            // still data to be sent to the server.
            client.LingerState = new LingerOption(true, 0);
            // Request authentication.
            NetworkStream clientStream = client.GetStream();
            NegotiateStream authStream = new NegotiateStream(clientStream, false);
            // Pass the NegotiateStream as the AsyncState object
            // so that it is available to the callback delegate.
            Task authenticateTask = authStream
                .AuthenticateAsClientAsync()
                .ContinueWith(task =>
                {
                    Console.WriteLine("Client ending authentication...");
                    Console.WriteLine("ImpersonationLevel: {0}", authStream.ImpersonationLevel);
                });

            Console.WriteLine("Client waiting for authentication...");
            // Wait until the result is available.
            authenticateTask.Wait();
            // Display the properties of the authenticated stream.
            AuthenticatedStreamReporter.DisplayProperties(authStream);
            // Send a message to the server.
            // Encode the test data into a byte array.
            byte[] message = Encoding.UTF8.GetBytes("Hello from the client.");
            Task writeTask = authStream
                .WriteAsync(message, 0, message.Length)
                .ContinueWith(task =>
                {
                    Console.WriteLine("Client ending write operation...");
                });

            writeTask.Wait();
            Console.WriteLine("Sent {0} bytes.", message.Length);
            // Close the client connection.
            authStream.Close();
            Console.WriteLine("Client closed.");
        }
    }

    // The following class displays the properties of an authenticatedStream.
    public class AuthenticatedStreamReporter
    {
        public static void DisplayProperties(AuthenticatedStream stream)
        {
            Console.WriteLine("IsAuthenticated: {0}", stream.IsAuthenticated);
            Console.WriteLine("IsMutuallyAuthenticated: {0}", stream.IsMutuallyAuthenticated);
            Console.WriteLine("IsEncrypted: {0}", stream.IsEncrypted);
            Console.WriteLine("IsSigned: {0}", stream.IsSigned);
            Console.WriteLine("IsServer: {0}", stream.IsServer);
        }
    }
}
Imports System.Text
Imports System.Net.Sockets
Imports System.Net.Security
Imports System.Net

Namespace Examples.NegotiateStreamExample

    Public Class ASynchronousAuthenticatingTcpClient

        Shared client As TcpClient = Nothing

        Public Shared Sub Main(args As String())
            ' Establish the remote endpoint for the socket.
            ' For this example, use the local machine.
            Dim ipHostInfo = Dns.GetHostEntry("localhost")
            Dim ipAddress = ipHostInfo.AddressList(0)

            ' Client and server use port 11000. 
            Dim remoteEP As New IPEndPoint(ipAddress, 11000)

            ' Create a TCP/IP socket.
            client = New TcpClient()

            ' Connect the socket to the remote endpoint.
            client.Connect(remoteEP)
            Console.WriteLine("Client connected to {0}.", remoteEP.ToString())

            ' Ensure the client does not close when there is 
            ' still data to be sent to the server.
            client.LingerState = (New LingerOption(True, 0))

            ' Request authentication.
            Dim clientStream = client.GetStream()
            Dim authStream As New NegotiateStream(clientStream, False)

            ' Pass the NegotiateStream as the AsyncState object 
            ' so that it is available to the callback delegate.
            Dim ar = authStream.BeginAuthenticateAsClient(
                New AsyncCallback(AddressOf EndAuthenticateCallback), authStream)

            Console.WriteLine("Client waiting for authentication...")

            ' Wait until the result is available.
            ar.AsyncWaitHandle.WaitOne()

            ' Display the properties of the authenticated stream.
            AuthenticatedStreamReporter.DisplayProperties(authStream)

            ' Send a message to the server.
            ' Encode the test data into a byte array.
            Dim message = Encoding.UTF8.GetBytes("Hello from the client.")
            ar = authStream.BeginWrite(message, 0, message.Length, 
                New AsyncCallback(AddressOf EndWriteCallback), authStream)
            ar.AsyncWaitHandle.WaitOne()
            Console.WriteLine("Sent {0} bytes.", message.Length)

            ' Close the client connection.
            authStream.Close()
            Console.WriteLine("Client closed.")

        End Sub

        ' The following method is called when the authentication completes.
        Public Shared Sub EndAuthenticateCallback(ar As IAsyncResult)

            Console.WriteLine("Client ending authentication...")
            Dim authStream = CType(ar.AsyncState, NegotiateStream)
            Console.WriteLine("ImpersonationLevel: {0}", authStream.ImpersonationLevel)

            ' End the asynchronous operation.
            authStream.EndAuthenticateAsClient(ar)

        End Sub

        ' The following method is called when the write operation completes.
        Public Shared Sub EndWriteCallback(ar As IAsyncResult)

            Console.WriteLine("Client ending write operation...")
            Dim authStream = CType(ar.AsyncState, NegotiateStream)

            ' End the asynchronous operation.
            authStream.EndWrite(ar)

        End Sub
    End Class

    ' The following class displays the properties of an AuthenticatedStream.
    Public Class AuthenticatedStreamReporter
        Public Shared Sub DisplayProperties(stream As AuthenticatedStream)
            Console.WriteLine("IsAuthenticated: {0}", stream.IsAuthenticated)
            Console.WriteLine("IsMutuallyAuthenticated: {0}", stream.IsMutuallyAuthenticated)
            Console.WriteLine("IsEncrypted: {0}", stream.IsEncrypted)
            Console.WriteLine("IsSigned: {0}", stream.IsSigned)
            Console.WriteLine("IsServer: {0}", stream.IsServer)
        End Sub
    End Class
End Namespace

다음 코드 예제에서는 클라이언트를 인증 하 고 클라이언트에서 보낸 메시지를 읽는 NegotiateStream 사용 하는 클라이언트-서버 연결의 서버 쪽을 보여 줍니다.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::Security;
using namespace System::Net::Sockets;
using namespace System::Security::Authentication;
using namespace System::Security::Principal;
using namespace System::Text;
using namespace System::IO;
using namespace System::Threading;

// ClientState is the AsyncState object.
private ref class ClientState
{
private:
   AuthenticatedStream^ authStream;
   TcpClient^ client;
   array<Byte>^buffer;
   StringBuilder^ message;
   ManualResetEvent^ waiter;

internal:
   ClientState( AuthenticatedStream^ a, TcpClient^ theClient )
   {
      authStream = a;
      client = theClient;
      message = nullptr;
      buffer = gcnew array<Byte>(2048);
      waiter = gcnew ManualResetEvent( false );
   }

internal:
   property TcpClient^ Client 
   {
      TcpClient^ get()
      {
         return client;
      }
   }

   property AuthenticatedStream^ AuthStream 
   {
      AuthenticatedStream^ get()
      {
         return authStream;
      }
  }

   property array<Byte>^ Buffer 
   {
      array<Byte>^ get()
      {
         return buffer;
      }

   }

   property StringBuilder^ Message 
   {
      StringBuilder^ get()
      {
         if ( message == nullptr )
                  message = gcnew StringBuilder;

         return message;
      }

   }

   property ManualResetEvent^ Waiter 
   {
      ManualResetEvent^ get()
      {
         return waiter;
      }

   }

};

public ref class AsynchronousAuthenticatingTcpListener
{
public:
   int Main()
   {
      
      // Create an IPv4 TCP/IP socket. 
      TcpListener^ listener = gcnew TcpListener( IPAddress::Any,11000 );
      
      // Listen for incoming connections.
      listener->Start();
      while ( true )
      {
         TcpClient^ clientRequest = nullptr;
         
         // Application blocks while waiting for an incoming connection.
         // Type CNTL-C to terminate the server.
         clientRequest = listener->AcceptTcpClient();
         Console::WriteLine( L"Client connected." );
         
         // A client has connected. 
         try
         {
            AuthenticateClient( clientRequest );
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( e );
            continue;
         }

      }
   }


   static void AuthenticateClient( TcpClient^ clientRequest )
   {
      NetworkStream^ stream = clientRequest->GetStream();
      
      // Create the NegotiateStream.
      NegotiateStream^ authStream = gcnew NegotiateStream( stream,false );
      
      // Save the current client and NegotiateStream instance 
      // in a ClientState object.
      ClientState^ cState = gcnew ClientState( authStream,clientRequest );
      
      // Listen for the client authentication request.
      authStream->BeginAuthenticateAsServer( gcnew AsyncCallback( EndAuthenticateCallback ), cState );
      
      // Wait until the authentication completes.
      cState->Waiter->WaitOne();
      cState->Waiter->Reset();
      authStream->BeginRead( cState->Buffer, 0, cState->Buffer->Length, gcnew AsyncCallback( EndReadCallback ), cState );
      cState->Waiter->WaitOne();
      
      // Finished with the current client.
      authStream->Close();
      clientRequest->Close();
   }


   // The following method is invoked by the
   // BeginServerAuthenticate callback delegate.
   static void EndAuthenticateCallback( IAsyncResult^ ar )
   {
      
      // Get the saved data.
      ClientState^ cState = dynamic_cast<ClientState^>(ar->AsyncState);
      TcpClient^ clientRequest = cState->Client;
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(cState->AuthStream);
      Console::WriteLine( L"Ending authentication." );
      
      // Any exceptions that occurred during authentication are
      // thrown by the EndServerAuthenticate method.
      try
      {
         
         // This call blocks until the authentication is complete.
         authStream->EndAuthenticateAsServer( ar );
      }
      catch ( AuthenticationException^ e ) 
      {
         Console::WriteLine( e );
         Console::WriteLine( L"Authentication failed - closing connection." );
         cState->Waiter->Set();
         return;
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( e );
         Console::WriteLine( L"Closing connection." );
         cState->Waiter->Set();
         return;
      }

      
      // Display properties of the authenticated client.
      IIdentity^ id = authStream->RemoteIdentity;
      Console::WriteLine( L"{0} was authenticated using {1}.", id->Name, id->AuthenticationType );
      cState->Waiter->Set();
   }


   static void EndReadCallback( IAsyncResult^ ar )
   {
      
      // Get the saved data.
      ClientState^ cState = dynamic_cast<ClientState^>(ar->AsyncState);
      TcpClient^ clientRequest = cState->Client;
      NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(cState->AuthStream);
      
      // Get the buffer that stores the message sent by the client.
      int bytes = -1;
      
      // Read the client message.
      try
      {
         bytes = authStream->EndRead( ar );
         cState->Message->Append( Encoding::UTF8->GetChars( cState->Buffer, 0, bytes ) );
         if ( bytes != 0 )
         {
            authStream->BeginRead( cState->Buffer, 0, cState->Buffer->Length, gcnew AsyncCallback( EndReadCallback ), cState );
            return;
         }
      }
      catch ( Exception^ e ) 
      {
         
         // A real application should do something
         // useful here, such as logging the failure.
         Console::WriteLine( L"Client message exception:" );
         Console::WriteLine( e );
         cState->Waiter->Set();
         return;
      }

      IIdentity^ id = authStream->RemoteIdentity;
      Console::WriteLine( L"{0} says {1}", id->Name, cState->Message );
      cState->Waiter->Set();
   }

};

void main()
{
   AsynchronousAuthenticatingTcpListener^ aatl = gcnew AsynchronousAuthenticatingTcpListener;
   aatl->Main();
}

using System;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Authentication;
using System.Security.Principal;
using System.Text;
using System.IO;
using System.Threading;

namespace Examples.NegotiateStreamExample
{
    public class AsynchronousAuthenticatingTcpListener
    {
        public static void Main()
        {
            // Create an IPv4 TCP/IP socket.
            TcpListener listener = new TcpListener(IPAddress.Any, 11000);
            // Listen for incoming connections.
            listener.Start();
            while (true)
            {
                TcpClient clientRequest;
                // Application blocks while waiting for an incoming connection.
                // Type CNTL-C to terminate the server.
                clientRequest = listener.AcceptTcpClient();
                Console.WriteLine("Client connected.");
                // A client has connected.
                try
                {
                    AuthenticateClient(clientRequest);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }

        public static void AuthenticateClient(TcpClient clientRequest)
        {
            NetworkStream stream = clientRequest.GetStream();
            // Create the NegotiateStream.
            NegotiateStream authStream = new NegotiateStream(stream, false);
            // Save the current client and NegotiateStream instance
            // in a ClientState object.
            ClientState cState = new ClientState(authStream, clientRequest);
            // Listen for the client authentication request.
            Task authTask = authStream
                .AuthenticateAsServerAsync()
                .ContinueWith(task => { EndAuthenticateCallback(cState); });

            // Any exceptions that occurred during authentication are
            // thrown by the EndAuthenticateAsServer method.
            try
            {
                // This call blocks until the authentication is complete.
                authTask.Wait();
            }
            catch (AuthenticationException e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Authentication failed - closing connection.");
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine("Closing connection.");
                return;
            }

            Task<int> readTask = authStream
                .ReadAsync(cState.Buffer, 0, cState.Buffer.Length);

            readTask
                .ContinueWith((task) => { EndReadCallback(cState, task.Result); })
                .Wait();
            // Finished with the current client.
            authStream.Close();
            clientRequest.Close();
        }

        private static void EndAuthenticateCallback(ClientState cState)
        {
            // Get the saved data.
            NegotiateStream authStream = (NegotiateStream)cState.AuthenticatedStream;
            Console.WriteLine("Ending authentication.");

            // Display properties of the authenticated client.
            IIdentity id = authStream.RemoteIdentity;
            Console.WriteLine("{0} was authenticated using {1}.",
                id.Name,
                id.AuthenticationType
            );
        }

        private static void EndReadCallback(ClientState cState, int bytes)
        {
            NegotiateStream authStream = (NegotiateStream)cState.AuthenticatedStream;
            // Read the client message.
            try
            {
                cState.Message.Append(Encoding.UTF8.GetChars(cState.Buffer, 0, bytes));
                if (bytes != 0)
                {
                    Task<int> readTask = authStream.ReadAsync(cState.Buffer, 0, cState.Buffer.Length);
                    readTask
                        .ContinueWith(task => { EndReadCallback(cState, task.Result); })
                        .Wait();

                    return;
                }
            }
            catch (Exception e)
            {
                // A real application should do something
                // useful here, such as logging the failure.
                Console.WriteLine("Client message exception:");
                Console.WriteLine(e);
                return;
            }
            IIdentity id = authStream.RemoteIdentity;
            Console.WriteLine("{0} says {1}", id.Name, cState.Message.ToString());
        }
    }
    // ClientState is the AsyncState object.
    internal class ClientState
    {
        private StringBuilder _message = null;

        internal ClientState(AuthenticatedStream a, TcpClient theClient)
        {
            AuthenticatedStream = a;
            Client = theClient;
        }
        internal TcpClient Client { get; }

        internal AuthenticatedStream AuthenticatedStream { get; }

        internal byte[] Buffer { get; } = new byte[2048];

        internal StringBuilder Message
        {
            get { return _message ??= new StringBuilder(); }
        }
    }
}

설명

NegotiateStream 클래스를 사용하여 인증하고 클라이언트와 서버 간에 전송되는 정보를 보호합니다. NegotiateStream사용하여 다음을 수행할 수 있습니다.

  • 가장 또는 위임을 위해 클라이언트의 자격 증명을 서버로 보냅니다.

  • 서버 인증을 요청합니다.

  • 데이터를 전송하기 전에 암호화 및/또는 서명합니다.

정보를 전송하기 전에 인증을 수행해야 합니다. 클라이언트는 인증이 완료될 때까지 차단하는 동기 AuthenticateAsClient 메서드 또는 인증이 완료되기를 기다리는 동안 차단되지 않는 비동기 BeginAuthenticateAsClient 메서드를 사용하여 인증을 요청합니다. 서버는 동기 AuthenticateAsServer 또는 비동기 BeginAuthenticateAsServer 메서드를 사용하여 인증을 요청합니다. 클라이언트 및 선택적으로 서버는 Negotiate 보안 프로토콜을 사용하여 인증됩니다. Kerberos 프로토콜은 클라이언트와 서버가 모두 지원하는 경우 인증에 사용됩니다. 그렇지 않으면 NTLM이 사용됩니다. NegotiateStream 클래스는 SSPI(보안 지원 공급자 인터페이스)를 사용하여 인증을 수행합니다.

인증에 성공하면 IsEncryptedIsSigned 속성을 확인하여 전송 중에 데이터를 보호하는 데 도움이 되는 NegotiateStream 사용할 보안 서비스를 결정해야 합니다. IsMutuallyAuthenticated 속성을 확인하여 상호 인증이 발생했는지 여부를 확인합니다. RemoteIdentity 속성을 사용하여 원격 클라이언트 또는 서버에 대한 정보를 가져올 수 있습니다.

인증에 실패하면 AuthenticationException 또는 InvalidCredentialException받게 됩니다. 이 경우 다른 자격 증명을 사용하여 인증을 다시 시도할 수 있습니다.

동기 Write 또는 비동기 BeginWrite 또는 WriteAsync 메서드를 사용하여 데이터를 보냅니다. 동기 Read 또는 비동기 ReadAsync 또는 BeginRead 메서드를 사용하여 데이터를 받습니다. 암호화 또는 서명과 같은 보안 서비스를 사용하도록 설정하면 NegotiateStream데이터에 자동으로 적용됩니다.

NegotiateStream NegotiateStream만들 때 제공하는 스트림을 사용하여 데이터를 전송합니다. 이 기본 스트림을 제공하는 경우 NegotiateStream 닫을 때 기본 스트림도 닫을지 여부를 지정하는 옵션이 있습니다.

생성자

NegotiateStream(Stream)

지정된 Stream사용하여 NegotiateStream 클래스의 새 인스턴스를 초기화합니다.

NegotiateStream(Stream, Boolean)

지정된 Stream 및 스트림 닫기 동작을 사용하여 NegotiateStream 클래스의 새 인스턴스를 초기화합니다.

속성

CanRead

기본 스트림을 읽을 수 있는지 여부를 나타내는 Boolean 값을 가져옵니다.

CanSeek

기본 스트림을 검색할 수 있는지 여부를 나타내는 Boolean 값을 가져옵니다.

CanTimeout

기본 스트림이 시간 초과를 지원하는지 여부를 나타내는 Boolean 값을 가져옵니다.

CanWrite

기본 스트림을 쓸 수 있는지 여부를 나타내는 Boolean 값을 가져옵니다.

ImpersonationLevel

서버에서 클라이언트의 자격 증명을 사용하는 방법을 나타내는 값을 가져옵니다.

InnerStream

AuthenticatedStream 데이터를 보내고 받는 데 사용되는 스트림을 가져옵니다.

(다음에서 상속됨 AuthenticatedStream)
IsAuthenticated

인증에 성공했는지 여부를 나타내는 Boolean 값을 가져옵니다.

IsEncrypted

NegotiateStream 데이터 암호화를 사용하는지 여부를 나타내는 Boolean 값을 가져옵니다.

IsMutuallyAuthenticated

서버와 클라이언트가 모두 인증되었는지 여부를 나타내는 Boolean 값을 가져옵니다.

IsServer

NegotiateStream 사용된 연결의 로컬 쪽이 서버로 인증되었는지 여부를 나타내는 Boolean 값을 가져옵니다.

IsSigned

이 스트림을 사용하여 보낸 데이터가 서명되었는지 여부를 나타내는 Boolean 값을 가져옵니다.

LeaveInnerStreamOpen

데이터를 보내고 받기 위해 이 AuthenticatedStream 사용하는 스트림이 열려 있는지 여부를 가져옵니다.

(다음에서 상속됨 AuthenticatedStream)
Length

기본 스트림의 길이를 가져옵니다.

Position

기본 스트림의 현재 위치를 가져오거나 설정합니다.

ReadTimeout

읽기 작업에서 데이터 대기를 차단하는 시간을 가져오거나 설정합니다.

RemoteIdentity

이 인증된 스트림을 공유하는 원격 파티의 ID에 대한 정보를 가져옵니다.

WriteTimeout

쓰기 작업에서 데이터 대기를 차단하는 시간을 가져오거나 설정합니다.

메서드

AuthenticateAsClient()

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 클라이언트에서 호출됩니다.

AuthenticateAsClient(NetworkCredential, ChannelBinding, String)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 클라이언트 자격 증명 및 채널 바인딩을 사용합니다.

AuthenticateAsClient(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 자격 증명, 인증 옵션 및 채널 바인딩을 사용합니다.

AuthenticateAsClient(NetworkCredential, String)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 클라이언트 자격 증명을 사용합니다.

AuthenticateAsClient(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 자격 증명 및 인증 옵션을 사용합니다.

AuthenticateAsClientAsync()

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 비동기 작업으로 인증하기 위해 클라이언트에서 호출합니다.

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 비동기 작업으로 인증하기 위해 클라이언트에서 호출합니다. 인증 프로세스는 지정된 클라이언트 자격 증명 및 채널 바인딩을 사용합니다.

AuthenticateAsClientAsync(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 비동기 작업으로 인증하기 위해 클라이언트에서 호출합니다. 인증 프로세스는 지정된 자격 증명, 인증 옵션 및 채널 바인딩을 사용합니다.

AuthenticateAsClientAsync(NetworkCredential, String)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 비동기 작업으로 인증하기 위해 클라이언트에서 호출합니다. 인증 프로세스는 지정된 클라이언트 자격 증명을 사용합니다.

AuthenticateAsClientAsync(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 비동기 작업으로 인증하기 위해 클라이언트에서 호출합니다. 인증 프로세스는 지정된 자격 증명 및 인증 옵션을 사용합니다.

AuthenticateAsServer()

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다.

AuthenticateAsServer(ExtendedProtectionPolicy)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 확장된 보호 정책을 사용합니다.

AuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 서버 자격 증명, 인증 옵션 및 확장된 보호 정책을 사용합니다.

AuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 서버 자격 증명 및 인증 옵션을 사용합니다.

AuthenticateAsServerAsync()

비동기 작업으로 클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다.

AuthenticateAsServerAsync(ExtendedProtectionPolicy)

비동기 작업으로 클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 확장된 보호 정책을 사용합니다.

AuthenticateAsServerAsync(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel)

비동기 작업으로 클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 서버 자격 증명, 인증 옵션 및 확장된 보호 정책을 사용합니다.

AuthenticateAsServerAsync(NetworkCredential, ProtectionLevel, TokenImpersonationLevel)

비동기 작업으로 클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 서버 자격 증명 및 인증 옵션을 사용합니다.

BeginAuthenticateAsClient(AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 클라이언트에서 호출됩니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsClient(NetworkCredential, ChannelBinding, String, AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 자격 증명 및 채널 바인딩을 사용합니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsClient(NetworkCredential, ChannelBinding, String, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 자격 증명, 인증 옵션 및 채널 바인딩을 사용합니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsClient(NetworkCredential, String, AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 자격 증명을 사용합니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsClient(NetworkCredential, String, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 클라이언트에서 호출됩니다. 인증 프로세스는 지정된 자격 증명 및 인증 옵션을 사용합니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsServer(AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 서버에서 호출됩니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsServer(ExtendedProtectionPolicy, AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 확장된 보호 정책을 사용합니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsServer(NetworkCredential, ExtendedProtectionPolicy, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 서버 자격 증명, 인증 옵션 및 확장된 보호 정책을 사용합니다. 이 메서드는 차단하지 않습니다.

BeginAuthenticateAsServer(NetworkCredential, ProtectionLevel, TokenImpersonationLevel, AsyncCallback, Object)

클라이언트-서버 연결에서 클라이언트 및 선택적으로 서버를 인증하기 위한 비동기 작업을 시작하기 위해 서버에서 호출됩니다. 인증 프로세스는 지정된 서버 자격 증명 및 인증 옵션을 사용합니다. 이 메서드는 차단하지 않습니다.

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

스트림에서 데이터를 읽고 지정된 배열에 저장하는 비동기 읽기 작업을 시작합니다.

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

비동기 읽기 작업을 시작합니다. (대신 ReadAsync(Byte[], Int32, Int32) 사용하는 것이 좋습니다.)

(다음에서 상속됨 Stream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

지정된 버퍼에서 스트림으로 Byte쓰는 비동기 쓰기 작업을 시작합니다.

BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

비동기 쓰기 작업을 시작합니다. (대신 WriteAsync(Byte[], Int32, Int32) 사용하는 것이 좋습니다.)

(다음에서 상속됨 Stream)
Close()

현재 스트림을 닫고 현재 스트림과 연결된 모든 리소스(예: 소켓 및 파일 핸들)를 해제합니다. 이 메서드를 호출하는 대신 스트림이 제대로 삭제되었는지 확인합니다.

(다음에서 상속됨 Stream)
CopyTo(Stream)

현재 스트림에서 바이트를 읽고 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyTo(Stream, Int32)

현재 스트림에서 바이트를 읽고 지정된 버퍼 크기를 사용하여 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream)

현재 스트림에서 바이트를 비동기적으로 읽고 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, CancellationToken)

지정된 취소 토큰을 사용하여 현재 스트림에서 바이트를 비동기적으로 읽고 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, Int32)

지정된 버퍼 크기를 사용하여 현재 스트림에서 바이트를 비동기적으로 읽고 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, Int32, CancellationToken)

지정된 버퍼 크기 및 취소 토큰을 사용하여 현재 스트림에서 바이트를 비동기적으로 읽고 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수만큼 고급입니다.

(다음에서 상속됨 Stream)
CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시를 생성하는 데 필요한 모든 관련 정보를 포함하는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
CreateWaitHandle()
사용되지 않음.
사용되지 않음.
사용되지 않음.

WaitHandle 개체를 할당합니다.

(다음에서 상속됨 Stream)
Dispose()

Stream사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Stream)
Dispose(Boolean)

NegotiateStream 사용하는 관리되지 않는 리소스를 해제하고 필요에 따라 관리되는 리소스를 해제합니다.

Dispose(Boolean)

AuthenticatedStream 사용하는 관리되지 않는 리소스를 해제하고 필요에 따라 관리되는 리소스를 해제합니다.

(다음에서 상속됨 AuthenticatedStream)
DisposeAsync()

NegotiateStream사용되는 관리되지 않는 관리되는 리소스를 비동기적으로 해제합니다.

DisposeAsync()

AuthenticatedStream사용되는 관리되지 않는 관리되는 리소스를 비동기적으로 해제합니다.

(다음에서 상속됨 AuthenticatedStream)
EndAuthenticateAsClient(IAsyncResult)

BeginAuthenticateAsClient호출로 시작된 보류 중인 비동기 클라이언트 인증 작업을 종료합니다.

EndAuthenticateAsServer(IAsyncResult)

BeginAuthenticateAsServer호출로 시작된 보류 중인 비동기 클라이언트 인증 작업을 종료합니다.

EndRead(IAsyncResult)

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)호출로 시작된 비동기 읽기 작업을 종료합니다.

EndRead(IAsyncResult)

보류 중인 비동기 읽기가 완료되기를 기다립니다. (대신 ReadAsync(Byte[], Int32, Int32) 사용하는 것이 좋습니다.)

(다음에서 상속됨 Stream)
EndWrite(IAsyncResult)

BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)호출로 시작된 비동기 쓰기 작업을 종료합니다.

EndWrite(IAsyncResult)

비동기 쓰기 작업을 종료합니다. (대신 WriteAsync(Byte[], Int32, Int32) 사용하는 것이 좋습니다.)

(다음에서 상속됨 Stream)
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
Flush()

버퍼링된 데이터가 기본 디바이스에 기록되도록 합니다.

FlushAsync()

이 스트림에 대한 모든 버퍼를 비동기적으로 지우고 버퍼링된 데이터가 기본 디바이스에 기록되도록 합니다.

(다음에서 상속됨 Stream)
FlushAsync(CancellationToken)

버퍼링된 데이터를 기본 디바이스에 비동기적으로 씁니다.

FlushAsync(CancellationToken)

이 스트림에 대한 모든 버퍼를 비동기적으로 지우고, 버퍼링된 데이터를 기본 디바이스에 쓰게 하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
ObjectInvariant()
사용되지 않음.

Contract대한 지원을 제공합니다.

(다음에서 상속됨 Stream)
Read(Byte[], Int32, Int32)

이 스트림에서 데이터를 읽고 지정된 배열에 저장합니다.

Read(Span<Byte>)

파생 클래스에서 재정의되는 경우 현재 스트림에서 바이트 시퀀스를 읽고 읽은 바이트 수만큼 스트림 내의 위치를 앞으로 이동합니다.

(다음에서 상속됨 Stream)
ReadAsync(Byte[], Int32, Int32)

현재 스트림에서 바이트 시퀀스를 비동기적으로 읽고 읽은 바이트 수만큼 스트림 내의 위치를 이동합니다.

(다음에서 상속됨 Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken)

이 스트림에서 데이터를 비동기적으로 읽고 지정된 배열에 저장합니다.

ReadAsync(Byte[], Int32, Int32, CancellationToken)

현재 스트림에서 바이트 시퀀스를 비동기적으로 읽고, 읽은 바이트 수만큼 스트림 내의 위치를 이동하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadAsync(Memory<Byte>, CancellationToken)

NegotiateStream 데이터를 비동기적으로 읽고 바이트 메모리 범위에 비동기 작업으로 저장합니다.

ReadAsync(Memory<Byte>, CancellationToken)

현재 스트림에서 바이트 시퀀스를 비동기적으로 읽고, 읽은 바이트 수만큼 스트림 내의 위치를 이동하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadAtLeast(Span<Byte>, Int32, Boolean)

현재 스트림에서 최소 바이트 수를 읽고 읽은 바이트 수만큼 스트림 내의 위치를 앞으로 이동합니다.

(다음에서 상속됨 Stream)
ReadAtLeastAsync(Memory<Byte>, Int32, Boolean, CancellationToken)

현재 스트림에서 최소 바이트 수를 비동기적으로 읽고, 읽은 바이트 수만큼 스트림 내의 위치를 이동하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadByte()

스트림에서 바이트를 읽고 스트림 내의 위치를 1 바이트씩 이동하거나 스트림의 끝에 있는 경우 -1 반환합니다.

(다음에서 상속됨 Stream)
ReadExactly(Byte[], Int32, Int32)

현재 스트림에서 count 바이트 수를 읽고 스트림 내의 위치를 이동합니다.

(다음에서 상속됨 Stream)
ReadExactly(Span<Byte>)

현재 스트림에서 바이트를 읽고 buffer 채워질 때까지 스트림 내의 위치를 이동합니다.

(다음에서 상속됨 Stream)
ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken)

현재 스트림에서 count 바이트 수를 비동기적으로 읽고 스트림 내의 위치를 이동하고 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadExactlyAsync(Memory<Byte>, CancellationToken)

현재 스트림에서 바이트를 비동기적으로 읽고, buffer 채워질 때까지 스트림 내의 위치를 이동하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
Seek(Int64, SeekOrigin)

NotSupportedExceptionthrow합니다.

SetLength(Int64)

기본 스트림의 길이를 설정합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
Write(Byte[], Int32, Int32)

지정된 버퍼 및 오프셋을 사용하여 기본 스트림에 지정된 Byte수를 씁니다.

Write(ReadOnlySpan<Byte>)

파생 클래스에서 재정의되는 경우 바이트 시퀀스를 현재 스트림에 쓰고 이 스트림 내의 현재 위치를 기록된 바이트 수만큼 앞으로 이동합니다.

(다음에서 상속됨 Stream)
WriteAsync(Byte[], Int32, Int32)

바이트 시퀀스를 현재 스트림에 비동기적으로 쓰고 이 스트림 내의 현재 위치를 기록된 바이트 수만큼 앞으로 이동합니다.

(다음에서 상속됨 Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

지정된 Byte수를 기본 스트림에 비동기적으로 씁니다.

WriteAsync(Byte[], Int32, Int32, CancellationToken)

바이트 시퀀스를 현재 스트림에 비동기적으로 쓰고, 기록된 바이트 수만큼 이 스트림 내의 현재 위치를 발전시키고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

지정된 Byte수를 기본 스트림에 비동기적으로 씁니다.

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

바이트 시퀀스를 현재 스트림에 비동기적으로 쓰고, 기록된 바이트 수만큼 이 스트림 내의 현재 위치를 발전시키고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
WriteByte(Byte)

스트림의 현재 위치에 바이트를 쓰고 스트림 내의 위치를 1 바이트씩 진행합니다.

(다음에서 상속됨 Stream)

확장 메서드

CopyToAsync(Stream, PipeWriter, CancellationToken)

취소 토큰을 사용하여 Stream 바이트를 비동기적으로 읽고 지정된 PipeWriter씁니다.

ConfigureAwait(IAsyncDisposable, Boolean)

비동기 삭제 가능 파일에서 반환된 작업에 대한 대기가 수행되는 방법을 구성합니다.

적용 대상

추가 정보