大网数据广告活动
账户与安全

Creating an Schannel Security Context

· 52CE 我爱测

Explains how to establish a security context that protects communications between a client and server.

To establish a security context that will protect communications between a client and server, both must participate in the following information exchange process:

Client

  1. The client calls the InitializeSecurityContext (General) function.
  2. Schannel begins creating a security context according to the rules of the selected security protocol. The function's return code indicates whether the client must call the function again. InitializeSecurityContext (General) may return a token that represents the context.
  3. If a token was returned, the client sends it to the server.
  4. When InitializeSecurityContext (General) returns SEC_E_OK, the client is done. If the function returns SEC_I_CONTINUE_NEEDED, the client must wait for the server to send it a token. When the client has the token from the server, it must call the InitializeSecurityContext (General) function again. (Return to step 2.)

Server

  1. The server waits for a client to send a message that contains a security token. The server passes the token received from the client into the AcceptSecurityContext (General) function.
  2. Schannel builds on the partial security context represented by the token. Schannel returns a token to the server, and a return code indicating whether the server must call the function again.
  3. If a token was returned, the server sends it to the client.
  4. When AcceptSecurityContext (General) returns SEC_E_OK, the server is done. If the function returns SEC_I_CONTINUE_NEEDED, then the server must wait for the client to send it a token. When the server has the token from the client, it must call the AcceptSecurityContext (General) function again. (Return to step 2.)

If either function returns a value other than SEC_E_OK, SEC_I_CONTINUE_NEEDED, or SEC_E_INCOMPLETE_MESSAGE (see the following paragraph) an error has occurred. The client and server should call the DeleteSecurityContext function to delete the partially established security context.

A special case that can alter client and server processing is when too little or too much information is sent to the client or server from the other party. In the case of too little information, both functions return SEC_E_INCOMPLETE_MESSAGE. For information about recognizing and handling insufficient or excess information, see Extra buffers Returned by Schannel.

Related topics

Performing Authentication Using Schannel

Mapping Certificates

Manually Validating Schannel Credentials

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。