Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
The example is based on SSLExampleCode but is simplified and is put in operational status.
The example connection goes to http://www.mozilla.org/
To operate with CSecureSocket class we need to include this header files:
And to add this libraries to .mmp file:
The connection is organized as Active Object. In ConnectL() method the RSocket socket is opened and connected:
_LIT( KIPAddress, " 22.214.171.124");
iState = EMakingSecureConnection;
if ( addr.Input( KIPAddress ) == KErrNone )
// server name is already a valid ip address
aAddr = addr.Address();
iAddress.SetPort( iPort );
iAddress.SetAddress( aAddr );
iAddress.SetFamily( KAfInet );
// Open a TCP socket
User::LeaveIfError( iSocket.Open( iSocketServer,
KProtocolInetTcp ) );
// Initiate socket connection
iSocket.Connect( iAddress, iStatus );
Then MakeSecureConnectionL() method accomplishes a handshake with the server:
iTlsSocket = CSecureSocket::NewL( iSocket, _L("SSL3.0"));
// start the handshake
iTlsSocket->StartClientHandshake( iStatus );
The page request goes is as follows:
_LIT8( KPage , "http://www.mozilla.org/");
// Create a GET request
iSndBuffer+=KSimpleGet; // "GET "
iSndBuffer+=KNewLine; // "\n"
// Send the request
iTlsSocket->Send( iSndBuffer, iStatus, iBytesSent );
Following two functions are retrieving the server response:
Download the example source code
The main implementation is in the SecureSocketCore.cpp file