createKeyFromCertContext Method
[This feature was implemented for MSXML 5.0 for Microsoft Office Applications. XML digital signatures are not supported in MXSML 6.0 and later.]
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 valid XMLDSigKey
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.
Applies To
Versioning
MSXML 5.0 for Microsoft Office Applications and later
See Also
createKeyFromCSP Method
createKeyFromHMACSecret Method
createKeyFromHMACSecretBinary Method
createKeyFromNode Method