×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    126

    CSecureSocket - StartClientHandShake fails

    I have got a UIQ Symbian application in which i connect to a ssl server (IIS), download the server certificate and a web page. I am using Thread,but is AO.
    Example code:
    iTotalBytesRead = 0;
    _LIT(KFile,"c:\\secsocout.txt");
    iOutputFileName = KFile;
    iConnectSettings.iPortNum =8443;
    iConnectSettings.iAddress=_L("192.168.100.56");
    iConnectSettings.iPage=_L8("/sony_cn/servlet/jp.co.softbrain.wes.sfa.esm_offl.msserver.MainServlet");
    iSndBuffer.Set((TUint8*)User::AllocL(KSendBufferSize),0,KSendBufferSize);
    iRcvBuffer.Set((TUint8*)User::AllocL(KReceiveBufferSize),0,KReceiveBufferSize);


    //self->iOutputFile->Replace(iEikonEnv->FsSession(),self->iOutputFileName,EFileWrite);


    User::LeaveIfError( iSocketServ.Connect());
    if (iInetAddr.Input(iConnectSettings.iAddress) != KErrNone)

    {

    User::LeaveIfError( iHostResolver.Open( iSocketServ, KAfInet, KProtocolInetTcp ));

    TNameEntry nameEntry;
    User::LeaveIfError (iHostResolver.GetByName(iConnectSettings.iAddress, nameEntry ));
    TSockAddr sockAddr = nameEntry().iAddr;
    iInetAddr = iInetAddr.Cast( sockAddr );
    iHostResolver.Close();
    }

    iInetAddr.SetPort( iConnectSettings.iPortNum );
    User::LeaveIfError( iSocket.Open( iSocketServ, KAfInet, KSockStream, KProtocolInetTcp ) );
    iSocket.Connect( iInetAddr, iStatus );
    User::WaitForRequest(iStatus);
    User::LeaveIfError(iStatus.Int());
    _LIT(KTLS1,"SSL3.0");
    User::After(2000000);
    if (iStatus == KErrNone)
    {

    iTlsSocket = CSecureSocket::NewL( iSocket, KTLS1 );

    iTlsSocket->FlushSessionCache();
    //TBuf8<2> buf;
    //buf.SetLength(2);
    //buf[0]=0; buf[1]=10;
    // iTlsSocket->SetAvailableCipherSuites( buf );

    //iTlsSocket->StartServerHandshake( iStatus );
    //User::WaitForRequest(iStatus);
    iTlsSocket->StartClientHandshake( iStatus );
    User::WaitForRequest(iStatus);
    // User::LeaveIfError(iStatus.Int());
    }
    iSndBuffer.SetLength( 0 );
    iRcvBuffer.SetLength( 0 );
    _LIT8(KSimpleGet, "GET ");
    _LIT8(KNewLine, "\n");
    iSndBuffer+=KSimpleGet;
    iSndBuffer+=iConnectSettings.iPage;
    iSndBuffer+=KNewLine;


    iTlsSocket->Send( iSndBuffer, iStatus);
    User::WaitForRequest(iStatus);
    //if (iStatus == KErrNone)
    iTlsSocket->RecvOneOrMore( iRcvBuffer, iStatus, iBytesSent);

    User::WaitForRequest( iStatus );

    iTotalBytesRead += iRcvBuffer.Length();
    iOutputFile->Write(iRcvBuffer);
    User::After( 9000000 );
    while(true)
    {
    // Put the received data in the output file & reset the receive buffer

    //iConsole->Printf(KFileErrorMessage);

    iRcvBuffer.SetLength( 0 );
    iTlsSocket->RecvOneOrMore( iRcvBuffer, iStatus,iBytesSent );
    User::WaitForRequest( iStatus );
    iTotalBytesRead += iRcvBuffer.Length();
    iOutputFile->Write(iRcvBuffer);

    // Case 1: error is KErrEof (message complete) or no data received, so stop
    if ( ( iStatus==KErrEof ) || ( iRcvBuffer.Length() == 0 ) )
    {
    //iConsole->Printf(KCompleteMessage, iTotalBytesRead);
    // Close the socket neatly
    //iRunState = EConnectionClosed;
    iTimer.After( iStatus, 1000000 );

    return;
    }

    1.Created Socket Connection
    2.Created CSecureSocket::NewL
    3.Call CSecureSocket->StartClientHandshake(iStatus)
    4.User::WaitForRequest(iStatus)
    Application is hanging at this place.

    StartClientHandshake(iStatus) doesn't return proper status.

    How to resolve this.
    Last edited by chengguangguo; 2006-02-17 at 06:31.

  2. #2
    Registered User
    Join Date
    Sep 2005
    Posts
    126

    Re: CSecureSocket - StartClientHandShake fails

    my dear friends,please help me.It drives me crazy.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Location
    Bangalore
    Posts
    45

    Re: CSecureSocket - StartClientHandShake fails

    hi
    did u resolved this problem?
    i am also facing the same one
    iTlsSocket->StartClientHandshake( iStatus );
    not responding

  4. #4
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    112

    Re: CSecureSocket - StartClientHandShake fails

    I have the same problem on phone debug mode.Are there any solution?

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: CSecureSocket - StartClientHandShake fails

    Yes, there may be: search for CSecureSocket in the Wiki, I think KIS000322 is for you.

  6. #6
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    112

    Re: CSecureSocket - StartClientHandShake fails

    Can you tell me the meaning of the third parameter?For example,I want to connet to "talk.google.com",and the third parameter is that value:"talk.google.com"?

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: CSecureSocket - StartClientHandShake fails

    Probably yes. Most XMPP servers use their 'real' domain as TLS domain (unless you explicitly configure something else). However I have not tried it with Google in particular.

  8. #8
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    112

    Re: CSecureSocket - StartClientHandShake fails

    On phone debug mode,when execute the unction:StartClientHandshake(),It will pop a dialog and tell me"Recive an distrust certification,do you want to go ong?",I choose "yes".And then RunL can not have any response from the server.The program hang!
    What's the problem?
    Flow you, I use the function :SetOpt(),It still doesn't work!
    Make me crazy!

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: CSecureSocket - StartClientHandShake fails

    Hmm, I hope you are not using the User::WaitForRequest what I have just noticed in the thread-starter post (if CSecureSocket::StartClientHandshake would do anything in the client-thread, User::WaitForRequest definitely kills it).
    Otherwise I have varying experiences with XMPP servers: Openfire works well even if I set 'wrong' domain name, while ejabberd passes/requests something that the Symbian TLS implementation can not handle at all.

  10. #10
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    112

    Re: CSecureSocket - StartClientHandShake fails

    I rearly use RunL in my program and not use User::WaitForRequest.
    From your explaination, I can't connet to Jabber server from Symbian TLS? But it can works on emulator without any problem.I want develope the third part software to talk with gtalk, can't I implement?

    On phone device, I use gprs to test my program.Through gprs,I can connet to internet, why the symbian's TLS cann't handle the the jabber's requests? What's the different between jabber and others ?

  11. #11
    Regular Contributor
    Join Date
    Jan 2007
    Location
    Bangalore
    Posts
    285

    Re: CSecureSocket - StartClientHandShake fails

    Instead of Using SSL3.0 use TLS1.0 .

    Jabber and GTalk!!! been there done that
    Please refer XMPP docs and RFC 3920 and 3921.

    I recommend not to use User::WaitForRequest() instead use SetActive()- RunL() combo. its more a healthy practice
    Regards
    Shashi Kiran G M

  12. #12
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: CSecureSocket - StartClientHandShake fails

    If it works in the emulator, remember to check the logfile: http://wiki.forum.nokia.com/index.php/Epocwind.out. Can it happen that you have a missing capability, and you have platsec warnings in it?
    So if it works in the emulator, it should also work in the device.

  13. #13
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    112

    Re: CSecureSocket - StartClientHandShake fails

    Thanks!
    I use TLS and not use User::WaitForRequest.
    I try the code again and again and I found sometimes shakehand can success.But even success,I send and receive data using the TLS socket offen have the problem(-36:KErrDisconnected or -25:KErrEof).

    Is that because the unstable network(I test the program through GPRS)?

    I can use RSocket to send and receive data well.But After I create a CSecureSocket and use it recevie data, KErrDisconnected error always appear.If GPRS is unstable, why I use RSocket is ok?

  14. #14
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    112

    Re: CSecureSocket - StartClientHandShake fails

    Hi:
    Is there no one know the problem?

  15. #15
    Regular Contributor
    Join Date
    Jan 2007
    Location
    Bangalore
    Posts
    285

    Re: CSecureSocket - StartClientHandShake fails

    CSecureSocket works perfectly. i have used it many times over. But some servers do disconnect if you are sending a wrong data packet For instance For Jabber servers you have to handle special charcters like <, > and & otherwise they get disconnected.
    No capability other that NetworkServices is required
    Regards
    Shashi Kiran G M

Similar Threads

  1. CVideoPlayerUtility video streaming fails on 7610?
    By k4l4 in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2008-11-18, 16:18
  2. HELP: HTTPS connection always fails!
    By xiaomingzhou in forum Symbian Networking & Messaging (Closed)
    Replies: 11
    Last Post: 2008-04-07, 05:14
  3. If Insertion fails
    By Alicia_S60 in forum Symbian
    Replies: 0
    Last Post: 2005-04-04, 06:57
  4. SIP INVITE fails with 488 error
    By apu_rath in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2004-11-02, 13:47
  5. Replies: 1
    Last Post: 2002-05-16, 19:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×