Page 1 of 2

undefined reference function

Posted: Fri Apr 23, 2021 3:01 pm
by RebootExpert
according to this thread in wolfssl forum https://www.wolfssl.com/forums/topic140 ... -pair.html
I should be able to use the function wolfSSL_CTX_check_private_key() to validate the ssl key pairs. I included the header file. and linked to the library cryptolib.a. However I got the undefined reference linker error. Any ideas what's wrong?

Re: undefined reference function

Posted: Fri Apr 23, 2021 3:36 pm
by RebootExpert
I am using 2.9.3

Re: undefined reference function

Posted: Mon Apr 26, 2021 2:01 pm
by Jon
Hi RebootExpert,

To use this function, you'll need to undefine NO_FILESYSTEM in nburn\include\crypto\platform\<platform>.h and then rebuild the crypto libraries.

In the next release of our tools, this will be used in the function

Code: Select all

IsSSL_CertNKeyValid()
, so you'll be able to use that to the same effect if you like.

Kind Regards,
Jon

Re: undefined reference function

Posted: Tue Apr 27, 2021 9:34 am
by RebootExpert
Hi Jon, I am using MOD54415 and there's only a user_settings.h header file in the directory of C:\nburn\include\crypto\platform\MOD5441X
So I undefine NO_FILESYSTEM in the file. and rebuild the libraries. Same error occur when I try to use it.

There's #ifndef directive check the NO_CERTS macro around the declaration and definition of wolfSSL_CTX_check_private_key()
But NO_CERTS is already undefined by default in user_settings.h

Re: undefined reference function

Posted: Tue Apr 27, 2021 2:55 pm
by Jon
Hi RebootExpert,

Sorry about that, the file you mentioned is the correct one. When you did the rebuild, is that from the command line or through NBEclipse? It shouldn't matter, but I'm just trying to collect as much info as possible. Would it be possible for you to send me your project code and your user_settings.h file?

You can email them directly to me at jcox(at)netburner.com. I'd like to see if I can replicate the issue you're experiencing.

Kind Regards,
Jon

Re: undefined reference function

Posted: Wed Apr 28, 2021 9:45 am
by RebootExpert
Hi Jon,
I rebuild the libraries through NBEclipse IDE. Here's my simple project I just made having the same error.

Code: Select all

#include <predef.h>
#include <stdio.h>
#include <ctype.h>
#include <startnet.h>
#include <autoupdate.h>
#include <dhcpclient.h>
#include <smarttrap.h>
#include <taskmon.h>
#include <NetworkDebug.h>

#include <crypto/ssl.h>

extern "C" {
void UserMain(void * pd);
}

const char * AppName="validation";

bool validation()
{
	WOLFSSL_CTX* ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method());
	int isValid = wolfSSL_CTX_check_private_key(ctx); //undefined reference error
	wolfSSL_CTX_free(ctx);
	return isValid == WOLFSSL_SUCCESS;
}

void UserMain(void * pd) {

    InitializeStack();
    GetDHCPAddressIfNecessary();
    OSChangePrio(MAIN_PRIO);
    EnableAutoUpdate();
    StartHTTP();
    EnableTaskMonitor();

    #ifndef _DEBUG
    EnableSmartTraps();
    #endif

    #ifdef _DEBUG
    InitializeNetworkGDB_and_Wait();
    #endif

    iprintf("Application started\n");
    
    validation();
    
    while (1) {
        OSTimeDly(TICKS_PER_SECOND);
    }
}


Re: undefined reference function

Posted: Wed Apr 28, 2021 9:48 am
by RebootExpert
and the header file for MOD5441X
user_settings.h
(7.3 KiB) Downloaded 482 times

Re: undefined reference function

Posted: Wed Apr 28, 2021 10:47 am
by Jon
Hey RebootExpert,

When you rebuild the system libraries in NBEclipse, does it list the platform that you've selected for the project during the rebuild, or does it show the CB34EX? This can happen if you select rebuild system libraries without having a project selected.

Just to make certain we're rebuilding the SSL libraries with the correct user_settings.h selected, would you mind trying the following:
Open a command terminal
Type

Code: Select all

set NBROOT
and make sure it lists your NNDK install directory.
Type

Code: Select all

set PLATFORM
and make sure it lists the MOD5441x. If it doesn't, type

Code: Select all

set PLATFORM=MOD5441X
Then navigate to

Code: Select all

<nndk_install>\system
and type

Code: Select all

make libs
This will force the library to be rebuilt with the settings using the MOD5441X folder specifically. Finally, go back to your project in NBEclipse and try to rebuild the project only, not the system libraries.

Kind Regards,
Jon

Re: undefined reference function

Posted: Wed Apr 28, 2021 11:26 am
by RebootExpert
I follow the steps. project still fail to compile.
Microsoft Windows [Version 10.0.19042.928]
(c) Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>set NBROOT
NBROOT=C:\nburn
NBROOTMINGW=C:\nburn

C:\WINDOWS\system32>set PLATFORM
PLATFORM=MOD5441X

C:\WINDOWS\system32>cd c:/nburn/system

c:\nburn\system>make libs
make[1]: Entering directory 'c:/nburn/system/cryptolib'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/cryptolib'
make[1]: Entering directory 'c:/nburn/system/debugLibrary'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/debugLibrary'
make[1]: Entering directory 'c:/nburn/system/lua'
c:/nburn/gcc-m68k/bin/make -C libraries system
make[2]: Entering directory 'c:/nburn/system/lua/libraries'
make[2]: Nothing to be done for 'system'.
make[2]: Leaving directory 'c:/nburn/system/lua/libraries'
make[1]: Leaving directory 'c:/nburn/system/lua'
make[1]: Entering directory 'c:/nburn/system/nb-libxively'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/nb-libxively'
make[1]: Entering directory 'c:/nburn/system/nbwifi'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/nbwifi'
make[1]: Entering directory 'c:/nburn/system/sshLibrary'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/sshLibrary'
make[1]: Entering directory 'c:/nburn/system/webclient'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/webclient'

c:\nburn\system>

Re: undefined reference function

Posted: Wed Apr 28, 2021 12:52 pm
by TomNB
Hello,

I am not sure about 2.9.3 as I don't have anything that old, but in 2.9.4 your application code works for me in nbeclipse with the only change being to comment out the #define #include NO_FILESYSTEM as Jon indicated. Although from the lib compilation you posted, it looks like the libs built, so that part is a bit confusing to me. I'm guessing after that your app still had a link error? Sorry this isn't more helpful, but I do not have access to 2.9.3.