Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI...

I'm working on an SSL client/server application, and I've generated a digital signature, and whenever I pass it to another function, the value of the digital signature changes in the middle of the function.
C++
int CLIENT::SSL_client_side(const char * MN, bool l, const char * digitalSignature, CkString Digital_Certificate)
 {
   CkSocket socket;

   bool success;
   success = socket.UnlockComponent("*******************");
   if (success != true) {
		printf("%s\n",socket.lastErrorText());
		return 0;}

    bool ssl;
    ssl = true;
    long maxWaitMillisec;
    maxWaitMillisec = 60000;

	//  The SSL server hostname may be an IP address, a domain name,
	//  or "localhost".  You'll need to change this:
    const char * sslServerHost;
    sslServerHost = "******";
    long sslServerPort;
    sslServerPort = 8123;



    //  Connect to the SSL server:
    success = socket.Connect(sslServerHost,sslServerPort,ssl,maxWaitMillisec);
    if (success != true) {
    printf("%s\n",socket.lastErrorText());
		return 0;}

    //  Set maximum timeouts for reading an writing (in millisec)
    socket.put_MaxReadIdleMs(50000);
    socket.put_MaxSendIdleMs(50000);


    success = socket.SendString("CLIENT PC: Hello Merchant! -EOM-");
    if (success != true) {
		printf("%s\n",socket.lastErrorText());
		return 0;}

	//CONNECTION 1: The "MERCHANT as a server"(in this example) is going to send
	//a "Hello Client! -EOM-" message.  Where the "PC as a client" will Read it:
    const char * receivedMsg;
    receivedMsg = socket.receiveUntilMatch("-EOM-");
	if (receivedMsg == 0 )
	 {
		printf("%s\n",socket.lastErrorText());
		return 0;
	 }

	//PRINT "CLIENT PC: Hello Client! -EOM-" on the "PC as a client" side
    printf("%s\n",receivedMsg);

	  //	cout<<"\n"<<DigSignature;      not good
	//CONNECTION 1: The "PC as a client" will display a message: "Enter your
	//Mobile Number:", and the user will enter his mobile number.
	//The Mobile Number will be sent to the "MERCHANT as a server"
	if (l == true)
	 {
 
		char MN[4096];
		printf("ENTER YOUR MOBILE NUMBER:");
		gets(MN);  

		success=socket.SendString((const char *)MN);
                  if (success != true) {
		printf("%s\n",socket.lastErrorText());
		return 0; }

		success = socket.SendString(Digital_Certificate);
		if (success != true) {
		printf("%s\n",socket.lastErrorText());
		return 0; }

		success = socket.SendString(digitalSignature);
		if (success != true) {
		printf("%s\n",socket.lastErrorText());
		return 0; }
	}
	//  Close the connection with the server
	//  Wait a max of 20 seconds (20000 millsec)
	//socket.Close(20000);
	//socket.Close(20000);
	//getch();
	return 0;
 }

And to be very specific, the contents of the digital Signature changes right after the following statement:
success = socket.Connect(sslServerHost,sslServerPort,ssl,maxWaitMillisec);

Please, need help

Regards.
Posted
Updated 22-May-13 11:44am
v2
Comments
CPallini 22-May-13 17:49pm    
Probably another thread is accessing that buffer. You might try (as debug technique) to copy the digitalSignature buffer on the very first statement of your function and use such copy in the rest of the function.
Sergey Alexandrovich Kryukov 22-May-13 21:19pm    
5!—SA
CPallini 23-May-13 1:42am    
Thank you, Sergey.
:-)
raniam 25-May-13 4:57am    
yes thank you, I've made a copy of the digitalSignature and it worked
lewax00 22-May-13 17:50pm    
Can you add the code that you generate that value in, and the code from that point to where this function is called (i.e. I assume it's a function, so the point from that function call to the call to this one)? I've seen some similar problems in the past, so it might be related (and if it is, I know how to fix it).

1 solution

Clean your build and rebuild it....some times this solved this type of problem;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900