Getting Validation Handle for Specific Certificate
Using the Toolkit

prevnext

Getting Validation Handle for Specific Certificate

The Vtk_ValidationGetValHdl validation function creates a validation handle for a specific certificate within a validation query. This function is useful if the application added certificates to the query using the Vtk_ValidationAddCertChain function or did not specify the Vtk_ValHdl when it added the certificate using the Vtk_ValidationAddCert or Vtk_ValidationAddCertRaw function.

Code Sample for Getting Validation Handle

/*
* getValHdl
*
* Function to obtain a Vtk_ValHdl from a Vtk_Validation structure.
* A Vtk_ValHdl can be obtained either at time of adding the
* certificate to the Vtk_Validation structure or by using the
* Vtk_ValidationGetValHdl function.
*
* Parameters:
* ctxt - ValiCert Validator Toolkit context
* val - Vtk_Validation structure
* cert - certificate for which to obtain the validation handle
* issuerCert - issuer certificate of the "cert"; this can be
* NULL if the issuer certificate has been previously
* added to the Vtk_Ctxt by calling Vtk_CtxtAddCert(s).
*/
int getValHdl(const Vtk_Ctxt *ctxt, Vtk_Validation *val,
const Vtk_Cert *cert, const Vtk_Cert *issuer)
{
Vtk_ValHdl *hdl = NULL;
Vtk_uint32 ret;


/*
* First add the certificate to the Vtk_Validation structure
*/
if ((ret = Vtk_ValidationAddCert(ctxt, val, cert, issuer, NULL))
!= VTK_OK)
{
showError("Vtk_ValidationAddCert", ret);
return -1;
}

/*
* IMPORTANT
*
* The application would need to continue with its normal
* processing such as perform the validation or add more
* certificates to be validated. The code for this processing
* could be inserted here. Once the application completes
* its processing, the application can obtain the validation
* handle for the certificate using the sample code below.
*
*/

/*
* Obtain the validation handle for the certificate
*/
if ((ret = Vtk_ValidationGetValHdl(ctxt, val, cert, issuer,
&hdl)) != VTK_OK)
{
showError("Vtk_ValidationGetValHdl", ret);
return -1;
}

/*
* The validation handle can now be used to obtain certificate
* revocation details through using the
* Vtk_ValidationAddReqExtForSingleCertHdl function.
*/


/*
* Free any resources associated with the validation handle.
*/
if (hdl)
Vtk_ValHdlDelete(hdl);

return 0;
} /* getValHdl */

prevnext


ValiCert, Inc.
http://www.valicert.com
Voice: +1.650.567.5469
Fax: (+1.650.254.2148
support@valicert.com