Hello all,
If anyone can help with my confusion here:
Let's say i'm working on an already existing module.
I've created modules in the past, this is not really my problem. My problem comes from an already existing module, let's call it my_module. In this module I'm adding a new functionality where i need to decrypt a jwt token parameter encrypted in AES.
The existing module main file, the file loaded by the main freeSWITCH loader is in C., let's say something like this:
#include <switch.h>
#include <switch_json.h>
#include <switch_stun.h>
#include <jwt.h>
#include "token_crypto.h" <-- This is my addition
...
<some stuff goes here>
at some point i do this:
plaintext_len = token_decrypt( *token_encoded, plaintext );
my token_crypto.h is
SWITCH_BEGIN_EXTERN_C
#include <stdio.h>
#include <string.h>
#include <openssl/ssl.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/sha.h>
void handleErrors(unsigned char *ciphertext);
int gcm_decrypt(unsigned char *ciphertext, int ciphertext_len,
unsigned char *aad, int aad_len,
unsigned char *tag,
unsigned char *key,
unsigned char *iv, int iv_len,
unsigned char *plaintext);
int token_decrypt( const char token_encoded, unsigned char *plaintext );
SWITCH_END_EXTERN_C
And then the actual implementation in token_crypto.cpp
I added the requirement to compile token_crypto in the Makefile.am like this:
mod_mymodule_la_SOURCES = \
base64url.cpp \
token_crypto.cpp \
mod_mymodule.c
The code then compiles ok, but when i try to load it i'm getting:
**/usr/local/freeswitch/mod/mod_mymodule.so: undefined symbol: token_decrypt**
I know the linker can't find the compiled references, but i just can't figure out how to link it all up...
call me stupid, but help me out 🤔
Regards,
David Villasmil
phone: +34669448337