Unicode C
Unicode C
Load a Private Key from XML Text
See more Private Key Examples
Demonstrates the Chilkat PrivateKey.LoadXml method, which loads a private key from XML text. The only argument is the XML string. Supported roots include RSAKeyValue, DSAKeyValue, ECCKeyValue, and Ed25519KeyValue.
Background: XML key representations such as
RSAKeyValue come from the .NET/XML-DSIG world, where keys are exchanged as XML elements. This loads that form — the inverse of GetXml — which is handy for interoperating with .NET code or systems built around XML signatures. It is a plaintext format, so protect the XML like any unencrypted key material.Chilkat Unicode C Downloads
#include <C_CkPrivateKeyW.h>
void ChilkatSample(void)
{
BOOL success;
HCkPrivateKeyW privKey;
const wchar_t *xmlText;
success = FALSE;
// Demonstrates the PrivateKey.LoadXml method, which loads a private key from XML text. The only
// argument is the XML string. Supported roots include RSAKeyValue, DSAKeyValue, ECCKeyValue,
// and Ed25519KeyValue.
privKey = CkPrivateKeyW_Create();
// The XML text of a private key (for example as produced by GetXml).
xmlText = L"<RSAKeyValue><Modulus>...</Modulus><Exponent>AQAB</Exponent>...</RSAKeyValue>";
success = CkPrivateKeyW_LoadXml(privKey,xmlText);
if (success == FALSE) {
wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privKey));
CkPrivateKeyW_Dispose(privKey);
return;
}
wprintf(L"Loaded a %s private key.\n",CkPrivateKeyW_keyType(privKey));
CkPrivateKeyW_Dispose(privKey);
}