networksecurity/tlsprovider/Test/tlstest2/verifyservercertstep.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file verifyservercertstep.cpp
       
    18  @internalTechnology
       
    19 */
       
    20 #include "verifyservercertstep.h"
       
    21 
       
    22 #include <tlsprovinterface.h>
       
    23 
       
    24 CVerifyServerCertStep::CVerifyServerCertStep()
       
    25 	{
       
    26 	SetTestStepName(KServerCertStep);
       
    27 	}
       
    28 
       
    29 TVerdict CVerifyServerCertStep::doTestStepPreambleL()
       
    30 	{
       
    31 	ConstructL();
       
    32 	
       
    33 	CTlsCryptoAttributes* atts = Provider()->Attributes();
       
    34 	
       
    35 	// set the session ID and "server" name (localhost)
       
    36 	atts->iSessionNameAndID.iSessionId = SessionId();
       
    37 	atts->iSessionNameAndID.iServerName.iAddress = KLocalHost; 
       
    38 	atts->iSessionNameAndID.iServerName.iPort = 443;
       
    39 	atts->idomainName.Copy(DomainNameL());
       
    40 	
       
    41 	// No client authentication or dialogs for this test, please
       
    42 	atts->iClientAuthenticate = EFalse;
       
    43 	atts->iDialogNonAttendedMode = ETrue;
       
    44 	
       
    45 	return EPass;
       
    46 	}
       
    47 	
       
    48 TVerdict CVerifyServerCertStep::doTestStepL()
       
    49 	{
       
    50 	INFO_PRINTF1(_L("Calling TLS Provider Verify Certificate."));
       
    51 	
       
    52 	CX509Certificate* cert = NULL;
       
    53 	TInt err = VerifyServerCertificateL(cert);
       
    54 	delete cert; // don't really need the cert
       
    55 	
       
    56 	TInt expectedResult;
       
    57 	
       
    58 	if (!GetIntFromConfig(ConfigSection(), KExpectedResult, expectedResult))
       
    59 		{
       
    60 		// failed to get expected result from config file... using KErrNone.
       
    61 		expectedResult = KErrNone;
       
    62 		}
       
    63 	
       
    64 	if (err != expectedResult)
       
    65 		{
       
    66 		INFO_PRINTF3(_L("Failed! TLS Provider returned error code %d, expecting %d."),
       
    67 			err, expectedResult);
       
    68 		SetTestStepResult(EFail);
       
    69 		return EFail;
       
    70 		}
       
    71 	else
       
    72 		{
       
    73 		INFO_PRINTF1(_L("Test passed."));
       
    74 		SetTestStepResult(EPass);
       
    75 		}
       
    76 	return TestStepResult();
       
    77 	}