hello, I'm intested to learn to use openSSL library can make my applications.
I start with a little and simple probe, but I couldn't compile it.
My probe has three four files: 
- Common_sslLib.h:

#ifndef __COMMON_SSLLIB__
#define __COMMON_SSLLIB__

#include <stdio.h>
#include <stdlib.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/ssl.h>


#define SERVHOST  "localhost"
#define SERVPORT  "26711"

void openSSLInit();
void handleError( void *, char *);

#endif

- common_sslLib.c
#include "common_sslLib.h"


//initialize openssl library
void openSSLInit()
{
    SSL_library_init();
    SSL_load_error_strings(); //load human-readable iformation about error codes.
//    action_to_seed_PRNG();
}

//manager erros function
void handleError( void *obj, char *msg )
{
    if( obj == NULL )
    {
        printf( "ˇˇˇˇˇ ERROR: %s !!!!!\n", msg );
        exit(-1);
    }
}

- client.c
//proper libraries declaration
#include "common_sslLib.h"

int main( int argc, char **argv )
{

//variables declaration
    BIO *bioSocket;
//end declaration variables

    openSSLInit();

//establish connection

    bioSocket = BIO_new_connect( SERVHOST ":" SERVPORT );
    handleError( bioSocket, "BIO_new_connect failed" );

    if( BIO_do_connect( bioSocket ) <= 0 )
    {
        printf(" ˇˇˇˇˇERROR: BIO_do_connect failed, unreachable host !!!!! " );
        exit(-1);
    }


    while( 1 );

    return 0;
}

- server.c

//proper libraries declaration
#include "common_sslLib.h"

int main( int argc, char **argv )
{
    //variables declaration
    BIO *sockAccept;

    //end variables

    openSSLInit();

    //create server socket (BIO is a class that contain a socket)
    sockAccept = SSL_new_accept( SERVPORT );
    handleError( sockAccept, "SSL_new_accept failed, server socket was not created" );

    //bind the server socket
    if( SSL_do_accept( sockAccept ) <= 0 )
        handleError( NULL, "SSL_do_accept failed, the address could not bind to 
socket" );

    //put the socket to accept the petitions
    if( SSL_do_accept( sockAccept ) <= 0 )
        handleError( NULL, "SSL_do_accept failed. Error  accepting connection" );


}

My problem is, when I compile the common_sslLib and client, I don't have any problem 
but when I compile the server I have some problems of the openssl server that it uses.

I compile then through of this way:

$export OPENSSL_LIB_DIR=/usr/include/openssl/
$gcc -I$OPENSSL_LIB_DIR -c common_sslLib.c
$gcc -I$OPENSSL_LIB_DIR -lssl -o client client.c  common_sslLib.o
$ gcc -I$OPENSSL_LIB_DIR -lssl -o server server.c  common_sslLib.o
/tmp/cc7Ff8Ri.o(.text+0x1e): En la función `main':
: referencia a `SSL_new_accept' sin definir
/tmp/cc7Ff8Ri.o(.text+0x42): En la función `main':
: referencia a `SSL_do_accept' sin definir
/tmp/cc7Ff8Ri.o(.text+0x66): En la función `main':
: referencia a `SSL_do_accept' sin definir
collect2: ld devolvió el estado de salida 1
$


In the folder /usr/include/openssl there are these files:

aes.h       conf.h     err.h       obj_mac.h      rc4.h        tls1.h
asn1.h      crypto.h   evp.h       ocsp.h         ripemd.h     tmdiff.h
asn1_mac.h  des.h      hmac.h      opensslconf.h  rsa.h        txt_db.h
asn1t.h     des_old.h  krb5_asn.h  opensslv.h     safestack.h  ui_compat.h
bio.h       dh.h       kssl.h      ossl_typ.h     sha.h        ui.h
blowfish.h  dsa.h      lhash.h     pem2.h         ssl23.h      x509.h
bn.h        dso.h      md2.h       pem.h          ssl2.h       x509v3.h
buffer.h    ebcdic.h   md4.h       pkcs12.h       ssl3.h       x509_vfy.h
cast.h      ec.h       md5.h       pkcs7.h        ssl.h
comp.h      engine.h   mdc2.h      rand.h         stack.h
conf_api.h  e_os2.h    objects.h   rc2.h          symhacks.h


Thanks.








________________________________________________________________________________________
Este mensaje ha sido analizado y protegido por la tecnologia antivirus 
www.trendmicro.es
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to