createKeyFromCertContext Method
[This feature was first implemented for MSXML 5.0.]Extracts a key from a specified certificate context obtainable from any of the CryptoAPI methods returning the CERT_CONTEXT structure.
C/C++ Syntax Using Smart Pointers
IXMLDSigKeyPtr keyRef = objIXMLDigitalSignatureEx->createKeyFromCertContext(pCertContext);
C/C++ Syntax
HRESULT createKeyFromCertContext( void* pCertContext, IXMLDSigKey** keyRef);
Parameters
- pCertContext [in]
- Pointer to a data structure that contains a certificate context that can be obtained from a CryptoAPI function returning a CERT_CONTEXT structure.
- keyRef [out, retval]
- In C/C++ this is a reference to the resultant key object. In C/C++ using smart pointer classes this is the key object.
Return Values
- S_OK
- The method succeeded and the resultant
keyRef
parameter points to a validXMLDSigKey
object. - E_FAIL
- The method failed and the resultant
keyRef
parameter is NULL.
Remarks
This method can be used to access a private key for signing and is available for C/C++ applications only.
Example
This C/C++ example illustrates how to sign an XML document with a key generated from a certificate context stored on your local machine. Generation of the key is encapsulated in the function GetCertContext
, which uses three CryptoAPI functions: CertOpenSystemStore
, CertFindCertificateInstore
, and CertClosestore
.
This example uses one resource file. You should get output similar to that provided at the end of the sample.
- Resource File (signature_template.rsa.xml)
- C/C++ Code (KeyFromCertContext.cpp)
- Output for the KeyFromCertContext Example
Applies To
Versioning
MSXML 5.0 and later
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.
See Also
createKeyFromCSP Method | createKeyFromHMACSecret Method | createKeyFromHMACSecretBinary Method | createKeyFromNode Method