[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-authenticode
Subject:    Re: Crypto API???
From:       Ryan Bolz <ryanbo () MICROSOFT ! COM>
Date:       1997-07-30 16:42:27
[Download RAW message or body]


CertCreateCertificateContext"

Creates a certificate context from an encoded certificate. The created
context is not put into a certificate store. It makes a copy of the
encoded certificate within the created context.
#include <wincrypt.h>
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(
  DWORD dwCertEncodingType,  //in
  const BYTE * pbCertEncoded,  //in
  DWORD cbCertEncoded        //in
);

Parameters
dwCertEncodingType
        The type of encoding used on the certificate. Currently defined
certificate encoding types are shown in the following table:
Encoding type   Value
X509_ASN_ENCODING       0x00000001

pbCertEncoded
        A pointer to the encoded certificate from which the context is
to be created.
cbCertEncoded
        The size, in bytes, of the encoded certificate.

Return Values
If unable to decode and create the certificate context, NULL is
returned. Otherwise, a pointer to a read-only CERT_CONTEXT is returned.
Call GetLastError to see the reason for any failures. This function has
the following error codes:
Error code      Description
E_INVALIDARG    Invalid certificate encoding type. Currently only
X509_ASN_ENCODING is supported.
CRYPT_E_OSS_ERROR       ASN.1 decoding error. Note, to get the OSS error
subtract CRYPT_E_OSS_ERROR from the returned error and see asn1code.h
for details on the error.

Remarks
The CERT_CONTEXT must be freed by calling CertFreeCertificateContext.
CertDuplicateCertificateContext can be called to make a duplicate.
CertSetCertificateContextProperty and CertGetCertificateContextProperty
can be called to store and read properties for the certificate.
Example
// EXAMPLE CODE FOR USING CertCreateCertificateContext() to create a
// certificate context from an encoded certificate.

// Assume that the application has a pointer (pbCertEncoded) to
// the encoded certificate, and the size of the encoded certificate
// (cbCertEncoded).

// Set up the variables.
BYTE*                    pbCertEncoded;    // Initialized elsewhere
DWORD                    cbCertEncoded;    // Initialized elsewhere
PCCERT_CONTEXT           pCertContext = NULL;

pCertContext = CertCreateCertificateContext(X509_ASN_ENCODING,
                    pbCertEncoded, cbCertEncoded);
if (!pCertContext)
    ; // An error occurred. Call GetLastError, and handle the condition.

// If the function succeeded, the new certificate context was created
// and is pointed to by pCertContext.

// Use the certificate context as necessary.
...

// Free memory.
CertFreeCertificateContext(pCertContext);

See Also
CertCreateCRLContext


> -----Original Message-----
> From: Ilana Ben-Hamou [SMTP:ilanab@SECURITY7.COM]
> Sent: Wednesday, July 30, 1997 2:20 AM
> To:   Authenticode@LISTSERV.MSN.COM
> Subject:      Crypto API???
>
> Hi,
>
> Is there anyone that knows about Crypto API
> "CertCreateCertificateContext"?
> Can I use it for loading certificate file to memory?, I tried, but I
> am
> getting  NULL in return.
>
> Any help can do,
>
> Thanks,
> Ilana.
>
> ----------------------------------------------------------------
> Users Guide http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
> contains important info including how to unsubscribe.  Save time,
> search
> the archives at http://microsoft.ease.lsoft.com/archives/index.html

----------------------------------------------------------------
Users Guide http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://microsoft.ease.lsoft.com/archives/index.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic