(C++) Workaround for the deprecated Crypt2.OpaqueSignBytes method
Shows how to replace the deprecated OpaqueSignBytes method. (Chilkat is moving away from the use of CkByteData.) Note: This example requires Chilkat v11.0.0 or greater.
#include <CkCrypt2.h>
#include <CkCert.h>
#include <CkByteData.h>
#include <CkBinData.h>
void ChilkatSample(void)
{
CkCrypt2 crypt;
CkCert cert;
// ...
// Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
//
bool success = crypt.SetSigningCert(cert);
// ...
// ...
// ...
const char *path = "c:/someDir/example.dat";
// ------------------------------------------------------------------------
// The OpaqueSignBytes method is deprecated:
CkByteData inData;
inData.loadFile(path);
CkByteData outData;
success = crypt.OpaqueSignBytes(inData,outData);
// ------------------------------------------------------------------------
// Workaround.
// (Chilkat is moving away from using CkByteData)
CkBinData bd;
bd.LoadFile(path);
// If successful, the contents of bd are replaced with the PKCS#7 signed-data.
success = crypt.OpaqueSignBd(bd);
}
|