The CryptEncodeObject and CryptDecodeObject functions can be used for encoding and decoding certificates, certificate extensions, certificate requests, certificate revocation lists, and certificate trust lists, to mention just a few. For a complete list of structures that can be encoded and decoded, see CryptEncodeObject/CryptDecodeObject Functions.
Two examples for using these functions are provided:
Certificates. For details on how to use CryptEncodeObject and CryptDecodeObject to encode and decode a certificate, see Certificate Encoding/Decoding.
Certificate requests. For details on how to use CryptEncodeObject to encode a certificate request, see Creating Certificate Requests, and Certificate Request Example Code.