Usage Flow
The standard usage flow of the kdc_proxy dynamic library is as follows:
- Load the dynamic library.
#include "kdc_proxy.h" void *handle = dlopen("libkdc_proxy.so", RTLD_LAZY); if (!handle) { // Handle the error. return; } - Obtain the function pointers.
SetLogCallback_t setLogCallback = (SetLogCallback_t)dlsym(handle, "SetLogCallback"); SetRAAgentTokenUrl_t setRaUrl = (SetRAAgentTokenUrl_t)dlsym(handle, "SetRAAgentTokenUrl"); SetKdcAgentUrl_t setKdcUrl = (SetKdcAgentUrl_t)dlsym(handle, "SetKdcAgentUrl"); SetCaFile_t setCa = (SetCaFile_t)dlsym(handle, "SetCaFile"); SetTlsCertAndKeyFile_t setTlsCert = (SetTlsCertAndKeyFile_t)dlsym(handle, "SetTlsCertAndKeyFile"); KdcProxyIdentityRegister_t identityRegister = (KdcProxyIdentityRegister_t)dlsym(handle, "KdcProxyIdentityRegister"); KdcTrustedRequest_t kdcRequest = (KdcTrustedRequest_t)dlsym(handle, "KdcTrustedRequest"); KdcFreePtr_t freePtr = (KdcFreePtr_t)dlsym(handle, "KdcFreePtr");
- Configure the URLs and certificates.
setLogCallback(connector_log); setRaUrl("https://api.example.com/global-trust-authority/agent/v1/tokens"); setKdcUrl("https://127.0.0.1:26068/rest/kdc_agent/v1/proxy"); setCa("/path/to/ca.crt"); setTlsCert("/path/to/tls.crt", "/path/to/tls.key", NULL); - Register the identity (called once at startup).
uint32_t ret = identityRegister(); if (ret != 0) { // Handle the error. return; } - Initiate a request.
char *output = NULL; uint32_t outputLen = 0; kdcRequest(35, input, inputLen, &output, &outputLen);
- Handle the result.
if (output) { freePtr(output); } - Closes the dynamic library.
dlclose(handle);
Parent topic: External API of kdc_proxy