1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
286 err = iTlsSocket->SetProtocol( prot ); |
286 err = iTlsSocket->SetProtocol( prot ); |
287 if ( err ) |
287 if ( err ) |
288 { |
288 { |
289 iTestStep->Log( _L("Failed to set Protocol for use: (%d)"),err ); |
289 iTestStep->Log( _L("Failed to set Protocol for use: (%d)"),err ); |
290 } |
290 } |
291 #ifdef HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
291 |
292 if(iTLSDialogMode) |
|
293 { |
|
294 iStatus = iTlsSocket->SetOpt(KSoDialogMode,KSolInetSSL,iTLSDialogModeValue); |
|
295 if ( iStatus != KErrNone ) |
|
296 { |
|
297 if(iExpectedErrorCode == iStatus.Int()) |
|
298 { |
|
299 iTestStep->Log( _L("iTlsSocket->SetOpt() failed with KErrArgument because of invalid DialogModeValue ")); |
|
300 iRunState = EConnectionClosed; |
|
301 iTestPassed = ETrue; |
|
302 } |
|
303 else |
|
304 { |
|
305 iTestStep->Log( _L("iTlsSocket->SetOpt() failed with error: %d"), iStatus.Int()); |
|
306 } |
|
307 iTlsSocket->Close(); |
|
308 iTimer.After( iStatus, 1000000 ); |
|
309 SetActive(); |
|
310 break; |
|
311 } |
|
312 } |
|
313 #endif // HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
|
314 // Set the domain name we're connecting to... |
292 // Set the domain name we're connecting to... |
315 iStatus = iTlsSocket->SetOpt(KSoSSLDomainName,KSolInetSSL, iDNSName); |
293 iStatus = iTlsSocket->SetOpt(KSoSSLDomainName,KSolInetSSL, iDNSName); |
316 if ( iStatus != KErrNone ) |
294 if ( iStatus != KErrNone ) |
317 { |
295 { |
318 iTestStep->Log( KStateErrReceivePage, iStatus.Int() ); |
296 iTestStep->Log( KStateErrReceivePage, iStatus.Int() ); |
350 |
328 |
351 |
329 |
352 |
330 |
353 if ( iStatus != KErrNone ) |
331 if ( iStatus != KErrNone ) |
354 { |
332 { |
355 #ifdef HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
333 TPtrC errorText = iTestStep->EpocErrorToText(iStatus.Int()); |
356 if(iExpectedErrorCode == iStatus.Int()) |
334 iTestStep->Log( _L("ESecureConnected:%S %d"),&errorText, iStatus.Int() ); |
357 { |
335 iTestStep->Log( KStateErrReceivePage, iStatus.Int() ); |
358 iTestStep->Log( _L("Received Untrusted CA")); |
336 iTestStep->Log( KStateErrReceivePage, iStatus.Int() ); |
359 iRunState = EConnectionClosed; |
337 iRunState = EConnectionClosed; |
360 iTestPassed = ETrue; |
338 iTestPassed = EFalse; |
361 } |
339 iTlsSocket->Close(); |
362 else |
340 iTimer.After( iStatus, 1000000 ); |
363 { |
341 SetActive(); |
364 #endif // HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
342 break; |
365 TPtrC errorText = iTestStep->EpocErrorToText(iStatus.Int()); |
343 } |
366 iTestStep->Log( _L("ESecureConnected:%S %d"),&errorText, iStatus.Int() ); |
|
367 iTestStep->Log( KStateErrReceivePage, iStatus.Int() ); |
|
368 iTestStep->Log( KStateErrReceivePage, iStatus.Int() ); |
|
369 iRunState = EConnectionClosed; |
|
370 iTestPassed = EFalse; |
|
371 #ifdef HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
|
372 } |
|
373 #endif // HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
|
374 iTlsSocket->Close(); |
|
375 iTimer.After( iStatus, 1000000 ); |
|
376 SetActive(); |
|
377 break; |
|
378 } |
|
379 else |
344 else |
380 { |
345 { |
381 iTestStep->Log( _L("ESecureConnected:KErrNone %d"),iStatus.Int() ); |
346 iTestStep->Log( _L("ESecureConnected:KErrNone %d"),iStatus.Int() ); |
382 } |
347 } |
383 |
348 |
754 void CTLSTest::DoCancel() |
719 void CTLSTest::DoCancel() |
755 { |
720 { |
756 // Cancel the connect |
721 // Cancel the connect |
757 iSocket.CancelConnect(); |
722 iSocket.CancelConnect(); |
758 } |
723 } |
759 #ifdef HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
724 |
760 void CTLSTest::ConnectL( const TDesC &aAddress, |
725 void CTLSTest::ConnectL( const TDesC &aAddress, |
761 const TInt aPortNum, |
726 const TInt aPortNum, |
762 const TDesC &aPage, |
727 const TDesC &aPage, |
763 const TDesC8 &aCipherSuite, |
728 const TDesC8 &aCipherSuite, |
764 const TInt aCipher, |
729 const TInt aCipher, |
765 const TInt aSimpleGet, |
730 const TInt aSimpleGet, |
766 const TInt aTestEndDelay, |
731 const TInt aTestEndDelay, |
767 const TDesC8& aDNSName , |
732 const TDesC8& aDNSName , |
768 const TDesC& aProtocol, |
733 const TDesC& aProtocol, |
769 TBool aUseGenericSocket, |
734 TBool aUseGenericSocket, |
770 TBool aEAPKeyDerivation, |
735 TBool aEAPKeyDerivation ) |
771 TBool aTLSDialogMode, |
|
772 TInt aTLSDialogModeValue, |
|
773 TInt aExpectedErrorCode ) |
|
774 #else |
|
775 void CTLSTest::ConnectL( const TDesC &aAddress, |
|
776 const TInt aPortNum, |
|
777 const TDesC &aPage, |
|
778 const TDesC8 &aCipherSuite, |
|
779 const TInt aCipher, |
|
780 const TInt aSimpleGet, |
|
781 const TInt aTestEndDelay, |
|
782 const TDesC8& aDNSName , |
|
783 const TDesC& aProtocol, |
|
784 TBool aUseGenericSocket, |
|
785 TBool aEAPKeyDerivation ) |
|
786 #endif // HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
|
787 { |
736 { |
788 #if 0 |
737 #if 0 |
789 iRunState = EDummyConnection; |
738 iRunState = EDummyConnection; |
790 TRequestStatus* p=&iStatus; |
739 TRequestStatus* p=&iStatus; |
791 User::RequestComplete( p, KErrNone ); |
740 User::RequestComplete( p, KErrNone ); |
822 iPage.Copy( aPage ); |
771 iPage.Copy( aPage ); |
823 iSimpleGet = aSimpleGet; |
772 iSimpleGet = aSimpleGet; |
824 iTestEndDelay = aTestEndDelay; |
773 iTestEndDelay = aTestEndDelay; |
825 iUseGenericSocket = aUseGenericSocket; |
774 iUseGenericSocket = aUseGenericSocket; |
826 iEAPKeyDerivation = aEAPKeyDerivation; |
775 iEAPKeyDerivation = aEAPKeyDerivation; |
827 #ifdef HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
776 |
828 iTLSDialogMode = aTLSDialogMode; |
|
829 iTLSDialogModeValue = aTLSDialogModeValue; |
|
830 iExpectedErrorCode = aExpectedErrorCode; |
|
831 #endif // HTTP_ALLOW_UNTRUSTED_CERTIFICATES |
|
832 // Print info to the log |
777 // Print info to the log |
833 iTestStep->Log( _L("*****Connecting to*****") ); |
778 iTestStep->Log( _L("*****Connecting to*****") ); |
834 iTestStep->Log( _L("%s:%d "), iAddress.PtrZ(), iPortNum ); |
779 iTestStep->Log( _L("%s:%d "), iAddress.PtrZ(), iPortNum ); |
835 |
780 |
836 |
781 |