Topic: how to add functions in ssl.c to libwolfssl.so

Hi, dear friend,
  I'm using wolfssl 4.5.0 to replace openssl.
  I'm using gcc to compile a c file.
  First ,execte ./configure --enable-opensslall --enable-opensslextra
  Then, make
   and, sudo make install
   and, compile my c file.but it says :
wrp.c:(.text+0x10e): undefined reference to `wolfSSL_add_all_algorithms'
wrp.c:(.text+0x113): undefined reference to `wolfSSL_RAND_status'
wrp.c:(.text+0x14d): undefined reference to `wolfSSL_BIO_new_mem_buf'
wrp.c:(.text+0x178): undefined reference to `wolfSSL_PEM_read_bio_X509'
wrp.c:(.text+0x189): undefined reference to `wolfSSL_BIO_free'
wrp.c:(.text+0x1a5): undefined reference to `wolfSSL_BIO_new_mem_buf'
wrp.c:(.text+0x1d0): undefined reference to `wolfSSL_PEM_read_bio_X509'
wrp.c:(.text+0x1e2): undefined reference to `wolfSSL_BIO_free'
wrp.c:(.text+0x1fe): undefined reference to `wolfSSL_BIO_new_mem_buf'
wrp.c:(.text+0x229): undefined reference to `wolfSSL_PEM_read_bio_PrivateKey'
wrp.c:(.text+0x23b): undefined reference to `wolfSSL_BIO_free'
wrp.c:(.text+0x2a2): undefined reference to `wolfSSL_CTX_use_certificate'
wrp.c:(.text+0x2e6): undefined reference to `wolfSSL_CTX_use_PrivateKey'
wrp.c:(.text+0x385): undefined reference to `wolfSSL_check_private_key'
wrp.c:(.text+0x3af): undefined reference to `wolfSSL_BIO_s_mem'
wrp.c:(.text+0x3b7): undefined reference to `wolfSSL_BIO_new'
wrp.c:(.text+0x3f0): undefined reference to `wolfSSL_BIO_s_mem'
wrp.c:(.text+0x3f8): undefined reference to `wolfSSL_BIO_new'
wrp.c:(.text+0x451): undefined reference to `wolfSSL_set_bio'
wrp.c:(.text+0x464): undefined reference to `wolfSSL_set_connect_state'
wrp.c:(.text+0x470): undefined reference to `wolfSSL_X509_STORE_new'
wrp.c:(.text+0x4ba): undefined reference to `wolfSSL_X509_STORE_add_cert'
wrp.c:(.text+0x4ed): undefined reference to `wolfSSL_X509_STORE_set_flags'
It seems all the above functions are in src/ssl.c.
Pls tell me how to add the functions to the libwolfssl.so

  Thks a lot.

Share

Re: how to add functions in ssl.c to libwolfssl.so

Hi wnqu,

Please make sure you include <wolfssl/options.h> prior to any other wolfSSL headers in your application. I am guessing that will resolve this. If not make sure you change the link to "-lwolfssl".

Thanks,
David Garske, wolfSSL

Share

Re: how to add functions in ssl.c to libwolfssl.so

Hi, dgarske,
I follow your advice to correct my code,but sorry,it dos'nt work.
I made a simple test.
the original ssl-tutorial-2.2 works very well.no problem during compiling and running.
but, if i add some code lines in the tcpcli01.c,the compiler allways reports some errors.

#include    "unp.h"
#include <wolfssl/options.h>
#include    <wolfssl/ssl.h>

int main(int argc, char **argv)
{
....
  if( (ssl = wolfSSL_new(ctx)) == NULL) {
    fprintf(stderr, "wolfSSL_new error.\n");
    exit(EXIT_FAILURE);
  }
   
#if 1
  {//added test code
    WOLFSSL_BIO *mRbio = wolfSSL_BIO_new(wolfSSL_BIO_s_mem());
    WOLFSSL_BIO *mWbio = wolfSSL_BIO_new(wolfSSL_BIO_s_mem());
    wolfSSL_set_bio(ssl, mRbio, mWbio);
  }
#endif

  wolfSSL_set_fd(ssl, sockfd);
  str_cli(stdin, ssl);        /* do it all */
  ...
}

after make,it says:
qn@Hisino-Linux-srv:~/smb/tls/wolfssl/ssl-tutorial-2.2/finished_src/echoclient$ make
gcc -Wall -o echoclient ../lib/*.c tcpcli01.c -I ../include -lm -lwolfssl
In file included from /usr/local/include/wolfssl/ssl.h:33:0,
                 from tcpcli01.c:2:
/usr/local/include/wolfssl/wolfcrypt/settings.h:2138:14: warning: #warning "For timing resistance / side-channel attack prevention consider using harden options" [-Wcpp]
             #warning "For timing resistance / side-channel attack prevention consider using harden options"
              ^
qn@Hisino-Linux-srv:~/smb/tls/wolfssl/ssl-tutorial-2.2/finished_src/echoclient$ make
gcc -Wall -o echoclient ../lib/*.c tcpcli01.c -I ../include -lm -lwolfssl
/tmp/cc3crctr.o: In function `main':
tcpcli01.c:(.text+0x2cf): undefined reference to `wolfSSL_BIO_s_mem'
tcpcli01.c:(.text+0x2d7): undefined reference to `wolfSSL_BIO_new'
tcpcli01.c:(.text+0x2e0): undefined reference to `wolfSSL_BIO_s_mem'
tcpcli01.c:(.text+0x2e8): undefined reference to `wolfSSL_BIO_new'
tcpcli01.c:(.text+0x303): undefined reference to `wolfSSL_set_bio'
collect2: error: ld returned 1 exit status
make: *** [echoclient] Error 1
qn@Hisino-Linux-srv:~/smb/tls/wolfssl/ssl-tutorial-2.2/finished_src/echoclient$
pls give more advice.
thank you

Share

Re: how to add functions in ssl.c to libwolfssl.so

I added the same code lines into wolfssl-4.5.0\examples\echoclient\echoclient.c

void echoclient_test(void* args)
{
  ......
    ssl = SSL_new(ctx);
    tcp_connect(&sockfd, yasslIP, port, doDTLS, 0, ssl);
#if 1
    {//added test code
    WOLFSSL_BIO *mRbio = wolfSSL_BIO_new(wolfSSL_BIO_s_mem());
    WOLFSSL_BIO *mWbio = wolfSSL_BIO_new(wolfSSL_BIO_s_mem());
    wolfSSL_set_bio(ssl, mRbio, mWbio);
    }
#endif
    SSL_set_fd(ssl, sockfd);
#if defined(USE_WINDOWS_API) && defined(CYASSL_DTLS) && defined(NO_MAIN_DRIVER)
    /* let echoserver bind first, TODO: add Windows signal like pthreads does */
    Sleep(100);
#endif
   ......
}

then wolfssl-4.5.0$ /make clean;make
as a result, no error occur.it's well done.
i'm confused what's the cause of the problem.
i'm expecting an advice.

Share

Re: how to add functions in ssl.c to libwolfssl.so

the problem has been solved.
the cause is that there is an old libwolfssl.so in dir,/usr/lib.evreytime i make the wolfssl-4.5.0 files, the gcc upgrades libwolfssl.so only in another dir,ie,/usr/local/lib.i deleted libwolfssl.so in /usr/lib,then everything looks good during making my code.

thank you anyway

Share