Hello, everyone,

 

I just cross compile the OpenSSL 0.9.7 under linux by mipsel-linux-gcc for
MIPS R3000, no error occur during the compiling process.

But, when I put the result lib to the hard platform, the openssl routines
can not be carried out and “segment fault” occurs.

Why? Does the OpenSSL not support the MIPS? How should I do to cross compile
for MIPS R3000?

 

The debug info is :

==============

GNU gdb 6.3

Copyright 2004 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain
conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB.  Type "show warranty" for details.

This GDB was configured as "--host=mipsel-linux
--target=mipsel-linux-uclibc".

(gdb) core core.186

Core was generated by `./drmCli'.

Program terminated with signal 11, Segmentation fault.

#0  0x0044cdac in EVP_des_cbc ()

(gdb) where

#0  0x0044cdac in EVP_des_cbc ()

#1  0x00427b4c in SSL_library_init ()

#2  0x00427b4c in SSL_library_init ()

#3  0x00400cd0 in transend (properlistInfo=0x100383f0 "",

    acIP=0x574f50 "192.168.18.155", acPORT=1111) at main.c:93

#4  0x00402a70 in cliskthread () at main.c:770

#5  0x004eac48 in pthread_start_thread ()

#6  0x00527c20 in __thread_start ()

Previous frame inner to this frame (corrupt stack?)

(gdb)

ulimit -c unlimited

mipsel-linux-gdb drmCli

core core.123

where

==================

The transend function is:

void transend(char *properlistInfo,const char* acIP,int acPORT)

{

 
/*---------------------------------------------------------------------- */

  //char P[2000];

  struct ProperTable p;

  struct ProperTable *pp;

  pp = &p; 

  

  int err;

  int sd;

  struct sockaddr_in sa;

  SSL_CTX* ctx;

  SSL*     ssl;

  X509*    server_cert;

  char*    str;

  char     buf2 [4096];

  char*    bufp;

  bufp = buf2;

  SSL_METHOD *meth;

         /*-------------------------------------------------*/

         //memset(P,0,sizeof(P));

         //i = propertable_gen(type,userid,pid,data,pp);

         pp = (struct ProperTable *)properlistInfo;          

          printf("transend p.Type=%x\n",(*pp).Type);

   printf("transend p.UserID=%x\n",(*pp).UserID);

   printf("transend p.PID=%x\n",(*pp).PID);

   printf("transend p.Lenth=%d\n",(*pp).Lenth);

   printf("transend p.Data=%s\n",(*pp).Data);

/*----------------------------------------------------------------*/

         SSLeay_add_ssl_algorithms();

  meth = SSLv2_client_method();

  SSL_load_error_strings();

  ctx = SSL_CTX_new (meth);                        CHK_NULL(ctx);

  CHK_SSL(err);

  

  /* ----------------------------------------------- */

  /* Create a socket and connect to server using normal socket calls. */

  

  sd = socket (AF_INET, SOCK_STREAM, 0);       CHK_ERR(sd, "socket");

 

  memset (&sa, '\0', sizeof(sa));

  sa.sin_family      = AF_INET;

 // sa.sin_addr.s_addr = inet_addr ("127.0.0.1");   /* Server IP */

//    sa.sin_addr.s_addr = inet_addr ("10.64.104.168");   /*Server IP */

         sa.sin_addr.s_addr = inet_addr (acIP);

//  sa.sin_port        = htons     (1111);          /* Server Port number */

   sa.sin_port = htons(acPORT);          /* Server Port number */

  

  err = connect(sd, (struct sockaddr*) &sa,sizeof(sa));       CHK_ERR(err,
"connect");

 

  /* ----------------------------------------------- */

  /* Now we have TCP conncetion. Start SSL negotiation. */

  

  ssl = SSL_new (ctx);                         CHK_NULL(ssl);    

  SSL_set_fd (ssl, sd);

  err = SSL_connect (ssl);                     CHK_SSL(err);

    

  /* Following two steps are optional and not required for

     data exchange to be successful. */

  

  /* Get the cipher - opt */

 

  printf ("SSL connection using %s\n", SSL_get_cipher (ssl));

  

  /* Get server's certificate (note: beware of dynamic allocation) - opt */

 

  server_cert = SSL_get_peer_certificate (ssl);       CHK_NULL(server_cert);

  printf ("Server certificate:\n");

  

  str = X509_NAME_oneline (X509_get_subject_name (server_cert),0,0);

  CHK_NULL(str);

  printf ("\t subject: %s\n", str);

  OPENSSL_free (str);

 

  str = X509_NAME_oneline (X509_get_issuer_name  (server_cert),0,0);

  CHK_NULL(str);

  printf ("\t issuer: %s\n", str);

  OPENSSL_free (str);

 

  /* We could do all sorts of certificate verification stuff here before

     deallocating the certificate. */

 

  X509_free (server_cert);

  

  /* --------------------------------------------------- */

  /* DATA EXCHANGE - Send a message and receive a reply. */

 

  //err = SSL_write (ssl, pp, sizeof(*pp));  CHK_SSL(err);  

  //err = SSL_write (ssl, properlistInfo, strlen(properlistInfo));
CHK_SSL(err);

  //print properlistInfo

 

  err = SSL_write (ssl, properlistInfo, sizeof(struct ProperTable));
CHK_SSL(err);

  err = SSL_read (ssl, buf2, sizeof(buf2) - 1);
CHK_SSL(err);

  buf2[err] = '\0';

  printf ("Got %d chars:'%s'\n", err, buf2);

 

 

  

  SSL_shutdown (ssl);  /* send SSL/TLS close_notify */

 

  /* Clean up. */

 

  close (sd);

  SSL_free (ssl);

  SSL_CTX_free (ctx);

  printf("transend return!\n");

//  return 0;

}

=============

Thanks a lot.

 

Cheng Yang

2007-2-7

Reply via email to