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

Encoding a CERT_INFO Structure

· 52CE 我爱测

The encoding process is the reverse of the decoding process described in Decoding a CERT_INFO Structure.

The encoding process is the reverse of the decoding process described in Decoding a CERT_INFO Structure. For example, the following procedure would add an encoded Issuer to a CERT_INFO structure. Also see the illustration that follows the procedure.

To add an encoded Issuer to a CERT_INFO structure

  1. Create a string containing the issuer name to be used.
  2. Create an array of CERT_RDN_ATTR structures, which will be initialized to contain the proper information about the issuer name string just created.
  3. Create an array of CERT_RDN structures, one of which has the information about the array of CERT_RDN_ATTR structures just initialized.
  4. Create a CERT_NAME_INFO structure that has a pointer to the array of CERT_RDN structures that just created.
  5. Call CryptEncodeObject to get the size of the output encoded BLOB, passing it the address of the CERT_NAME_INFO structure that you just created.
  6. Allocate memory for the output encoded BLOB.
  7. Call CryptEncodeObject again, passing it the same information, but now passing it the address of the memory just allocated.
  8. Set the Issuer.cbData member of the CERT_INFO structure to the size returned in step 5, and the Issuer.pbData member to the address obtained in step 6. The encoded Issuer BLOB now resides there.

adding an encoded issuer to a cert\-info structure

To initialize and encode some certificate extension information, use the following procedure. Also see the illustration that follows the procedure.

To add encoded extension information to a CERT_INFO structure

  1. Create and initialize an extension information structure—for this example, it is a CERT_BASIC_CONSTRAINTS_INFO structure.
  2. Call CryptEncodeObject, passing it the address of the structure just created, to get the size of the output encoded BLOB.
  3. Allocate memory for the output encoded BLOB.
  4. Call CryptEncodeObject again, passing the same information, except now pass in the address of the allocated memory.
  5. Create an array of CERT_EXTENSION structures.
  6. Initialize one of the CERT_EXTENSION structures so that the pszObjId is the proper string for the data contained in Value, and that Value contains the encrypted data BLOB that was output from the call to CryptEncodeObject.
  7. Initialize the rgExtension member of the CERT_INFO structure to point to the array of CERT_EXTENSION structures.

adding encoded extension information to a cert\-info structure

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)

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

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