pkiutilities/ocsp/test/engine.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 // Copyright (c) 2001-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 #include "engine.h"
       
    17 #include "transport.h"
       
    18 #include "panic.h"
       
    19 #include "logger.h"
       
    20 #include "main.h"
       
    21 #include "requestlogger.h"
       
    22 #include "testfilterparameters.h"
       
    23 #include <miscutil.h>
       
    24 
       
    25 #include <ocsp.h>
       
    26 #include <x509cert.h>
       
    27 
       
    28 #include <ocsptransport.h>
       
    29 
       
    30 #include "ocspsupporttransport.h"
       
    31 
       
    32 // Log file created by the transport filter
       
    33 _LIT(KFilterLogFileName, "\\tocsphttpfilter.log");
       
    34 
       
    35 const TInt KTimeMilliToMicro = 1000;
       
    36 
       
    37 CTOCSPEngine* CTOCSPEngine::NewL(CTOCSPLogger& aLog)
       
    38 	{
       
    39 	CTOCSPEngine* self = new (ELeave) CTOCSPEngine(aLog);
       
    40 	CleanupStack::PushL(self);
       
    41 	self->ConstructL();
       
    42 	CleanupStack::Pop(self);
       
    43 	return self;
       
    44 	}
       
    45 
       
    46 
       
    47 CTOCSPEngine::CTOCSPEngine(CTOCSPLogger& aLog) :
       
    48 	CActive(EPriorityNormal),
       
    49 	iLog(aLog)
       
    50 	{
       
    51 	CActiveScheduler::Add(this);
       
    52 	}
       
    53 
       
    54 
       
    55 void CTOCSPEngine::ConstructL()
       
    56 	{
       
    57 	// Open file server session
       
    58 	User::LeaveIfError(iFs.Connect());
       
    59 	iCertUtils = CCertUtils::NewL(iFs);
       
    60 
       
    61 	// Create cancellation timer
       
    62 	iTimer = CCallbackTimer::NewL(*this);
       
    63 	}
       
    64 
       
    65 CTOCSPEngine::~CTOCSPEngine()
       
    66 	{
       
    67     Cancel(); // Calls Reset along the way
       
    68 	Destroy();
       
    69 	delete iTimer;
       
    70 	delete iCertUtils;
       
    71 	delete iUnifiedCertStore;
       
    72 	iFs.Close();
       
    73 	}
       
    74 
       
    75 // Common code between destructor and ResetL()
       
    76 void CTOCSPEngine::Destroy()
       
    77 	{
       
    78 	delete iParams;
       
    79 	iParams = NULL;
       
    80 	
       
    81 	delete iClient;
       
    82 	iClient = NULL;
       
    83 	
       
    84 	iSubjectCerts.ResetAndDestroy();
       
    85 	iIssuerCerts.ResetAndDestroy();
       
    86 	iSigningCerts.ResetAndDestroy();
       
    87 	iTransportLog.Close();
       
    88 
       
    89 	delete iRequestLog;
       
    90 	iRequestLog = NULL;
       
    91 
       
    92 	// Not owned
       
    93 	iTransport = NULL;
       
    94 	}
       
    95 
       
    96 void CTOCSPEngine::Reset()
       
    97 	{
       
    98 	Destroy();
       
    99 
       
   100 	// Delete and reset all the filter parameters
       
   101 	DeleteFilterParameters();
       
   102 
       
   103 	iUseDirectAuthorisation = EFalse;
       
   104 	iUseCADelegateAuthorisation = EFalse;
       
   105 	iUseCADirectAuthorisation = EFalse;
       
   106 	iUseAllSchemes = EFalse;
       
   107 
       
   108 	iCancelTime = 0;
       
   109 	}
       
   110 
       
   111 
       
   112 void CTOCSPEngine::StartL(TRequestStatus& aStatus)
       
   113 	{	
       
   114 	iParams = COCSPParameters::NewL();	
       
   115 	InitDirectAuthL();
       
   116 
       
   117 	// Delete the transport filter log file
       
   118 	TInt err = iFs.Delete(KFilterLogFileName);
       
   119 	if ((err != KErrNone) && (err != KErrNotFound))
       
   120 		{
       
   121 		if (iVerbose)
       
   122 			{
       
   123 			iLog.LogL(_L("Failed to delete transport filter log file ("), ETrue);
       
   124 			iLog.LogL(KFilterLogFileName);
       
   125 			iLog.LogL(_L("). Error: "), ETrue);
       
   126 			iLog.LogL(err);
       
   127 			}
       
   128 		User::Leave(err);
       
   129 		}
       
   130 
       
   131 	iState = EInitCertStore;
       
   132 	aStatus = KRequestPending;
       
   133 	iOriginalRequestStatus = &aStatus;
       
   134 	SetActive();
       
   135 		
       
   136 	// Initialise unified cert store here if it doesn't already exist
       
   137 	if (!iUnifiedCertStore)
       
   138 		{
       
   139 		iUnifiedCertStore = CUnifiedCertStore::NewL(iFs, ETrue);
       
   140 		iUnifiedCertStore->Initialize(iStatus);
       
   141 		}
       
   142 	else
       
   143 		{
       
   144 		TRequestStatus* status = &iStatus;
       
   145 		User::RequestComplete(status, KErrNone);
       
   146 		}
       
   147 	}
       
   148 
       
   149 void CTOCSPEngine::EndL(TRequestStatus& aStatus)
       
   150 	{
       
   151 	Reset();
       
   152 	CleanUpDirectAuthL(aStatus);
       
   153 	}
       
   154 
       
   155 
       
   156 void CTOCSPEngine::SetURIL(const TDesC8& aURI, TBool aUseAIA)
       
   157 	{
       
   158 	iParams->SetURIL(aURI, aUseAIA);
       
   159 	}
       
   160 
       
   161 
       
   162 void CTOCSPEngine::SetDefaultTransportL()
       
   163 	{
       
   164 	iIap = 0;
       
   165 	MOCSPTransport* trans = COCSPTransportDefault::NewL(iIap);
       
   166 	CleanupStack::PushL(trans);
       
   167 	SetTransportL(trans);
       
   168 	CleanupStack::Pop(trans);
       
   169 	}
       
   170 
       
   171 
       
   172 void CTOCSPEngine::SetTestTransportL(const TDesC& aResponseFile, const TDesC* aRequestFile)
       
   173 	{
       
   174 	CTOCSPTransport* trans = CTOCSPTransport::NewL(aResponseFile, aRequestFile);
       
   175 	CleanupStack::PushL(trans);
       
   176 	SetTransportL(trans);
       
   177 	CleanupStack::Pop(trans);
       
   178 	}
       
   179 
       
   180 void CTOCSPEngine::SetOcspSupportTransportL()
       
   181 	{
       
   182 	iIap = 0;
       
   183 	Swi::COcspSupportTransport* trans = Swi::COcspSupportTransport::NewL(iIap);
       
   184 
       
   185 	CleanupStack::PushL(trans);
       
   186 	SetTransportL(trans);
       
   187 	CleanupStack::Pop(trans);
       
   188 	}
       
   189 
       
   190 void CTOCSPEngine::SetTransportRetryCount(TUint aRetryCount)
       
   191 	{
       
   192 	__ASSERT_DEBUG(iTransport != NULL, Panic(KErrTOCSPScriptParameterError));
       
   193 	iParams->SetRetryCount(aRetryCount);
       
   194 	}
       
   195 
       
   196 void CTOCSPEngine::SetTransportTimeout(TInt aTimeout)
       
   197 	{
       
   198 	__ASSERT_DEBUG(iTransport != NULL, Panic(KErrTOCSPScriptParameterError));
       
   199 	iParams->SetTimeout(aTimeout);
       
   200 	}
       
   201 
       
   202 void CTOCSPEngine::SetTransportL(MOCSPTransport* aTransport)
       
   203 	{
       
   204 	// To log the request, we wrap the transport in our request logger transport
       
   205 	if (iRequestLog)
       
   206 		{
       
   207 		aTransport = CTOCSPRequestLogger::NewL(*iRequestLog, aTransport);
       
   208 		}
       
   209 	iTransport = aTransport;
       
   210 	iParams->SetTransport(aTransport);
       
   211 	}
       
   212 
       
   213 void CTOCSPEngine::SetFilterParameters(TInt aNumDelayResp, TInt aCountDropResp,
       
   214 			TInt countCorruptHTTPDataHeader, TInt countCorruptHTTPDataBodySizeLarge, TInt countCorruptHTTPDataBodySizeSmall, 
       
   215 			TInt aCountCorruptOCSPData, 
       
   216 			TInt aCountInternalErrorResp, TInt aCountTryLaterResp,
       
   217 			TInt aCountSigValidateFailure)
       
   218 	{
       
   219 	iNumDelayResp = aNumDelayResp;
       
   220 	iCountDropResp = aCountDropResp;
       
   221 	iCountCorruptHTTPDataHeader = countCorruptHTTPDataHeader;
       
   222 	iCountCorruptHTTPDataBodySizeLarge = countCorruptHTTPDataBodySizeLarge;
       
   223 	iCountCorruptHTTPDataBodySizeSmall = countCorruptHTTPDataBodySizeSmall;
       
   224 	iCountCorruptOCSPData = aCountCorruptOCSPData;
       
   225 	iCountInternalErrorResp = aCountInternalErrorResp;
       
   226 	iCountTryLaterResp = aCountTryLaterResp;
       
   227 	iCountSigValidateFailure = aCountSigValidateFailure;
       
   228 	}
       
   229 
       
   230 void CTOCSPEngine::AddCertL(const TDesC8& aSubject, const TDesC8& aIssuer)
       
   231 	{
       
   232 	// Create certificate objects and keep hold of them - these are added
       
   233 	// to the client later
       
   234 
       
   235 	CX509Certificate* subject = CX509Certificate::NewLC(aSubject);
       
   236 	User::LeaveIfError(iSubjectCerts.Append(subject));
       
   237 	CleanupStack::Pop(subject);  // Now owned through iCerts
       
   238 
       
   239 	CX509Certificate* issuer = CX509Certificate::NewLC(aIssuer);
       
   240 	User::LeaveIfError(iIssuerCerts.Append(issuer));
       
   241 	CleanupStack::Pop(issuer);  // Now owned through iCerts
       
   242 	
       
   243 	// Add certificates to parameter
       
   244 	iParams->AddCertificateL(*subject, *issuer);
       
   245 	}
       
   246 
       
   247 void CTOCSPEngine::ReadTransportLogL()
       
   248 	{
       
   249 	// Read and process the transport filter log (if it exists)
       
   250 	RFile file;
       
   251 	TInt size;
       
   252 	if (file.Open(iFs, KFilterLogFileName, EFileShareAny | EFileRead) != KErrNone)
       
   253 		{
       
   254 		return;
       
   255 		}
       
   256 
       
   257 	CleanupClosePushL(file);
       
   258 	file.Size(size);
       
   259 	RFileReadStream fileStream(file);
       
   260 	CleanupClosePushL(fileStream);
       
   261 	RBuf8 logBuffer;
       
   262 	logBuffer.CreateL(size);
       
   263 	CleanupClosePushL(logBuffer);
       
   264 	fileStream.ReadL(logBuffer, size);
       
   265 	TInt readPos = 0;
       
   266 	TPtrC8 currentLine;
       
   267 	while (MiscUtil::ReadNonEmptyLineL(logBuffer, readPos, currentLine))
       
   268 		{
       
   269 		TLex8 lex(currentLine);
       
   270 		TPtrC8 methodName = lex.NextToken();
       
   271 
       
   272 		// Validate and store the entry
       
   273 		TTransportLog logEntry;
       
   274 		if (methodName.Length() <= 4)
       
   275 			{
       
   276 			logEntry.iHttpMethod.Copy(methodName);
       
   277 			logEntry.iHttpMethod.UpperCase();
       
   278 			}
       
   279 
       
   280 		// Get the timestamps and calculate transaction duration
       
   281 		TInt64 startTime = 0;
       
   282 		TInt64 endTime = 0;
       
   283 		lex.SkipSpaceAndMark(); User::LeaveIfError(lex.Val(startTime));
       
   284 		lex.SkipSpaceAndMark(); User::LeaveIfError(lex.Val(endTime));
       
   285 		logEntry.iTransDurationMs = static_cast<TInt64>((endTime - startTime) / KTimeMilliToMicro);
       
   286 
       
   287 		iTransportLog.AppendL(logEntry);
       
   288 		}
       
   289 	CleanupStack::PopAndDestroy(3, &file); // fileStream, logBuffer
       
   290 	}
       
   291 
       
   292 TBool CTOCSPEngine::ReadLineL(const TDesC8& aBuffer, TInt& aPos, TPtrC8& aLine) const
       
   293 	{
       
   294 	TBool endOfBuffer = EFalse;	
       
   295 	aLine.Set(NULL, 0);
       
   296 
       
   297 	TInt bufferLength = aBuffer.Length();	
       
   298 	__ASSERT_ALWAYS(aPos >=0 && aPos <= bufferLength, User::Leave(KErrArgument));
       
   299 
       
   300 	// Skip blank lines
       
   301 	while (aPos < bufferLength) 
       
   302 		{
       
   303 		TChar  c = aBuffer[aPos];
       
   304 		if (c != '\r' && c != '\n')
       
   305 			{
       
   306 			break;
       
   307 			}
       
   308 		aPos++;
       
   309 		}
       
   310 
       
   311 	// Find the position of the next delimter		
       
   312 	TInt endPos = aPos;	
       
   313 	while (endPos < bufferLength)
       
   314 		{
       
   315 		TChar c = aBuffer[endPos];
       
   316 		if (c == '\n' || c == '\r') 
       
   317 			{
       
   318 			break;
       
   319 			}	
       
   320 		++endPos;
       
   321 		}
       
   322 
       
   323 	if (endPos != aPos)	
       
   324 		{
       
   325 		TInt tokenLen = endPos - aPos;
       
   326 		aLine.Set(&aBuffer[aPos], tokenLen);
       
   327 		}
       
   328 	else 
       
   329 		{
       
   330 		return ETrue; // End of buffer
       
   331 		}			
       
   332 
       
   333 	aPos = endPos;
       
   334 	return endOfBuffer;
       
   335 	}
       
   336 
       
   337 void CTOCSPEngine::LogResponseDetailsL()
       
   338 	{
       
   339 	if (iVerbose)
       
   340 		{
       
   341 		_LIT(KDateFormat, "%F%H:%T %D/%M/%Y");
       
   342 		TBuf<32> timeString;
       
   343 
       
   344 		iLog.LogL(_L("Response details:\n"));
       
   345 
       
   346 		TTime timeNow;
       
   347 		timeNow.UniversalTime();
       
   348 		timeNow.FormatL(timeString, KDateFormat);
       
   349 		iLog.LogL(_L("  Response generation time == "));
       
   350 		iLog.LogL(timeString);
       
   351 		iLog.LogL(_L("\n"));
       
   352 
       
   353 		TBuf<10> indexText;
       
   354 
       
   355 		for (int i = 0 ; i < iClient->TransactionCount() ; ++i)
       
   356 			{
       
   357 			const COCSPResponse* response = iClient->Response(i);
       
   358 
       
   359 			iLog.LogL(_L("  Response "));
       
   360 			indexText.Zero();
       
   361 			indexText.Num(i);
       
   362 			iLog.LogL(indexText);
       
   363 			iLog.LogL(_L(":\n"));
       
   364 
       
   365 			if (response)
       
   366 				{
       
   367 				response->ProducedAt().FormatL(timeString, KDateFormat);
       
   368 				iLog.LogL(_L("    producedAt == "));
       
   369 				iLog.LogL(timeString);
       
   370 				iLog.NewLineL();
       
   371 	
       
   372 				TInt count = response->CertCount();
       
   373 				for (TInt index = 0; index < count; ++index)
       
   374 					{
       
   375 					const COCSPResponseCertInfo& certInfo = response->CertInfo(index);
       
   376 
       
   377 					iLog.LogL(_L("    Cert "));
       
   378 					indexText.Zero();
       
   379 					indexText.Num(index);
       
   380 					iLog.LogL(indexText);
       
   381 					iLog.LogL(_L(" Results:"));
       
   382 			
       
   383 					iLog.LogL(_L("\n      status == "));
       
   384 					iLog.LogL(TranslateResultL(certInfo.Status()));
       
   385 
       
   386 					certInfo.ThisUpdate().FormatL(timeString, KDateFormat);
       
   387 					iLog.LogL(_L("\n      thisUpdate == "));
       
   388 					iLog.LogL(timeString);
       
   389 					iLog.NewLineL();
       
   390 
       
   391 					if (certInfo.NextUpdate())
       
   392 						{
       
   393 						timeString.Zero();
       
   394 						certInfo.NextUpdate()->FormatL(timeString, KDateFormat);
       
   395 						iLog.LogL(_L("      nextUpdate == "));
       
   396 						iLog.LogL(timeString);
       
   397 						iLog.NewLineL();
       
   398 						}
       
   399 
       
   400 					if (certInfo.RevocationTime())
       
   401 						{
       
   402 						timeString.Zero();
       
   403 						certInfo.RevocationTime()->FormatL(timeString, KDateFormat);
       
   404 						iLog.LogL(_L("      revocationTime == "));
       
   405 						iLog.LogL(timeString);
       
   406 						iLog.NewLineL();
       
   407 						}
       
   408 					}
       
   409 				}
       
   410 			else
       
   411 				{
       
   412 				iLog.LogL(_L("    missing"));			
       
   413 				iLog.NewLineL();
       
   414 				}
       
   415 
       
   416 			const TOCSPOutcome& outcome = iClient->Outcome(i);
       
   417 			iLog.LogL(_L("    Validation outcome:"));
       
   418 			iLog.NewLineL();
       
   419 			iLog.LogL(_L("      status == "));
       
   420 			iLog.LogL(TranslateStatusL(outcome.iStatus));
       
   421 			iLog.NewLineL();
       
   422 			iLog.LogL(_L("      result == "));
       
   423 			iLog.LogL(TranslateResultL(outcome.iResult));
       
   424 			iLog.NewLineL();
       
   425 			}
       
   426 
       
   427 		iLog.LogL(_L("  OCSP Summary result == "));
       
   428 		iLog.LogL(TranslateResultL(iClient->SummaryResult()));
       
   429 		iLog.NewLineL();
       
   430 		}
       
   431 	}
       
   432 
       
   433 
       
   434 void CTOCSPEngine::RunL()
       
   435 	{
       
   436 	TInt err = iStatus.Int();
       
   437 	if( KErrNotFound != err && KErrNone != err )
       
   438 		{
       
   439 		iLog.LogL(_L("Client request completed with code:"));  
       
   440 		iLog.LogL(err);
       
   441 		iLog.NewLineL();
       
   442 		User::LeaveIfError(err);
       
   443 		}
       
   444 
       
   445 	if( KErrNotFound == err )
       
   446 		{
       
   447 		iLog.LogL(_L("Item not found leave code"));
       
   448 		iLog.NewLineL();
       
   449 		// Handle error
       
   450 		User::Leave(err);
       
   451 		}
       
   452 
       
   453 	switch (iState)
       
   454 		{
       
   455 		case EInitCertStore:
       
   456 			// Remove all certificates so we always start from the same state 
       
   457 			iCertUtils->RemoveCertsL(*iUnifiedCertStore, iStatus);
       
   458 			iState = ERemovingCerts;
       
   459 			SetActive();
       
   460 			break;
       
   461 			
       
   462 		case EAddingCert:
       
   463 		case ERemovingCerts:
       
   464 			User::RequestComplete(iOriginalRequestStatus, KErrNone);
       
   465 			break;
       
   466 
       
   467 		case EChecking:
       
   468 			// Cancel the timer
       
   469 			iTimer->Cancel();
       
   470 			ReadTransportLogL();
       
   471 			LogResponseDetailsL();
       
   472 			User::RequestComplete(iOriginalRequestStatus, KErrNone);
       
   473 			break;
       
   474 
       
   475 		default:
       
   476             User::Panic(_L("TOCSP"), 1);
       
   477 			break;
       
   478 		}
       
   479 	}
       
   480 
       
   481 TInt CTOCSPEngine::RunError(TInt aError)
       
   482     {
       
   483     User::RequestComplete(iOriginalRequestStatus, aError);
       
   484     return KErrNone;
       
   485     }
       
   486 
       
   487 void CTOCSPEngine::DoCancel()
       
   488 	{
       
   489     switch (iState)
       
   490         {
       
   491 		case EInitCertStore:
       
   492 			if (iUnifiedCertStore)
       
   493 				{
       
   494 				iUnifiedCertStore->CancelInitialize();
       
   495 				}
       
   496 			break;
       
   497 			
       
   498 		case EAddingCert:
       
   499 		case ERemovingCerts:
       
   500             iCertUtils->Cancel();
       
   501             break;
       
   502 
       
   503 		case EChecking:
       
   504             iClient->CancelCheck();
       
   505             break;
       
   506 
       
   507 		default:
       
   508             User::Panic(_L("TOCSP"), 1);
       
   509 			break;
       
   510         }
       
   511 
       
   512 	Reset();
       
   513     User::RequestComplete(iOriginalRequestStatus, KErrCancel);
       
   514 	}
       
   515 
       
   516 // Implementation of MTimerRun
       
   517 void CTOCSPEngine::TimerRun(TInt /*aError*/)
       
   518 	{
       
   519 	// Cancellation timer expired
       
   520 	this->Cancel();
       
   521 	}
       
   522 
       
   523 void CTOCSPEngine::SetValidationTimeL(const TTime& aWhen)
       
   524 	{
       
   525 	iParams->SetValidationTimeL(aWhen);
       
   526 	}
       
   527 
       
   528 
       
   529 void CTOCSPEngine::SetNonce(const TBool aNonce)
       
   530 	{
       
   531 	iParams->SetUseNonce(aNonce);
       
   532 	}
       
   533 
       
   534 
       
   535 void CTOCSPEngine::SetMaxStatusAgeL(TUint aMaxAge)
       
   536 	{
       
   537 	iParams->SetMaxStatusAgeL(aMaxAge);
       
   538 	}
       
   539 
       
   540 void CTOCSPEngine::InitDirectAuthL()
       
   541 	{
       
   542 	// Add OCSP test harness to cert store client list
       
   543 	TName name(_L("TOCSP"));
       
   544 	iCertUtils->AddApplicationL(name, TUid::Uid(KTOCSP_UID));
       
   545 	}
       
   546 
       
   547 void CTOCSPEngine::CleanUpDirectAuthL(TRequestStatus& aStatus)
       
   548 	{
       
   549 	iOriginalRequestStatus = &aStatus;
       
   550 	aStatus = KRequestPending;
       
   551 
       
   552 	// Should always succeed, as called after InitDirectAuthL
       
   553 	iCertUtils->RemoveApplicationL(TUid::Uid(KTOCSP_UID));
       
   554 
       
   555 	//This should remove the X509Certs, which is the only certificate type used by the test.
       
   556 	iCertUtils->RemoveCertsL(*iUnifiedCertStore, iStatus);
       
   557 	iState = ERemovingCerts;
       
   558 	SetActive();
       
   559 	}
       
   560 
       
   561 void CTOCSPEngine::AddDirectAuthorisationCert(const TDesC& aCert,
       
   562                                               const TDesC& aLabel,
       
   563                                               TRequestStatus& aStatus)
       
   564 	{
       
   565     TRAPD(err, DoAddDirectAuthorisationCertL(aCert, aLabel, aStatus));
       
   566     if (err != KErrNone)
       
   567         {
       
   568         Cancel();
       
   569         TRequestStatus* status = &aStatus;
       
   570         User::RequestComplete(status, err);
       
   571         }
       
   572     }
       
   573 
       
   574 void CTOCSPEngine::DoAddDirectAuthorisationCertL(const TDesC& aCert,
       
   575 												 const TDesC& aLabel,
       
   576 												 TRequestStatus& aStatus)
       
   577 	{
       
   578 	TPtrC cert = aCert;
       
   579 	HBufC8* certData = ReadDataL(iFs, cert);
       
   580 	CleanupStack::PushL(certData);
       
   581 
       
   582 	// Make and store the certificate
       
   583 	CX509Certificate* cert2 = CX509Certificate::NewLC(*certData);
       
   584 	User::LeaveIfError(iSigningCerts.Append(cert2));
       
   585 	CleanupStack::Pop(cert2);  // Now owned through iCerts
       
   586 	CleanupStack::PopAndDestroy(certData);
       
   587 	
       
   588 	iUseDirectAuthorisation = ETrue;
       
   589 
       
   590 	iCert = aCert;
       
   591 	iLabel = aLabel;	
       
   592 
       
   593 	iOriginalRequestStatus = &aStatus;
       
   594 	aStatus = KRequestPending;
       
   595 	iState = EAddingCert;
       
   596 
       
   597 	iCertUtils->AddCert(iLabel, EX509Certificate, ECACertificate, KTOCSP_UID,
       
   598 						KNullDesC, iCert, *iUnifiedCertStore, iStatus);
       
   599 	SetActive();
       
   600 	}
       
   601 
       
   602 
       
   603 /**
       
   604 	Called when "AUTHORISATIONCERT AUTHCERTNONE" is parsed.
       
   605 	Sets a flag so an instance of COCSPDirectAuthorisationScheme
       
   606 	is allocated in PrepareAuthorisationSchemeL().
       
   607 	
       
   608 	This function should be used to test direct authorisation
       
   609 	without supplying a cert.  When a cert is supplied, use
       
   610 	AddDirectAuthorisationCert().
       
   611 	
       
   612 	@see AddDirectAuthorisationCert
       
   613 	@see UseCADelegateAuthorisation
       
   614  */
       
   615 void CTOCSPEngine::UseDirectAuthorisation()
       
   616 	{
       
   617 	iUseDirectAuthorisation = ETrue;	
       
   618 	}
       
   619 
       
   620 /**
       
   621 	Called when a "CADELEGATE" command is parsed.  It sets
       
   622 	a flag so that an instance of COCSPDelegateAuthorisationScheme
       
   623 	is allocated in PrepareAuthorisationSchemeL().
       
   624 
       
   625 	@see AddDirectAuthorisationCert
       
   626 	@see UseCADirectAuthorisation
       
   627  */
       
   628 void CTOCSPEngine::UseCADelegateAuthorisation()
       
   629 	{
       
   630 	iUseCADelegateAuthorisation = ETrue;
       
   631 	}
       
   632 
       
   633 /**
       
   634 	Called when "CADIRECT" command is parsed.  It sets
       
   635 	a flag so that an instance of COCSPCaDirectAuthorisationScheme
       
   636 	is allocated in PrepareAuthorisationSchemeL().
       
   637 
       
   638 	@see AddDirectAuthorisationCert
       
   639 	@see UseCADelegateAuthorisation
       
   640  	@see UseDirectAuthorisation
       
   641 */
       
   642 void CTOCSPEngine::UseCADirectAuthorisation()
       
   643 	{
       
   644 	iUseCADirectAuthorisation = ETrue;
       
   645 	}
       
   646 
       
   647 /**
       
   648 	Called when "ALLSCHEMES" command is parsed.  It sets
       
   649 	a flag so that all schemes are allocated in 
       
   650 	PrepareAuthorisationSchemeL().
       
   651 
       
   652 	@see AddDirectAuthorisationCert
       
   653 	@see UseCADelegateAuthorisation
       
   654 	@see UseCADirectAuthorisation
       
   655 */
       
   656 void CTOCSPEngine::UseAllAuthorisationSchemes()
       
   657 	{
       
   658 	iUseAllSchemes = ETrue;
       
   659 	}
       
   660 
       
   661 void CTOCSPEngine::PrepareAuthorisationL()
       
   662 	{
       
   663 	if (iUseAllSchemes)
       
   664 		{
       
   665 		// iUseDirectAuthorisation may also be set because
       
   666 		// "AUTHORISATIONCERT" commands have been parsed.
       
   667 		ASSERT(!(iUseCADelegateAuthorisation || iUseCADirectAuthorisation));
       
   668 
       
   669 		// This assumes __SECURITY_PLATSEC_ARCH__ is defined.  This
       
   670 		// is the case because AddAllAuthorisationSchemesL() is added
       
   671 		// to 9.1 onwards.
       
   672 		iParams->AddAllAuthorisationSchemesL(TUid::Uid(KTOCSP_UID), *iUnifiedCertStore);
       
   673 		return;
       
   674 		}
       
   675 
       
   676 	if (iUseDirectAuthorisation)
       
   677 		{
       
   678 		// Register direct authorisation object with OCSP validator
       
   679 		COCSPDirectAuthorisationScheme* scheme =  
       
   680 			COCSPDirectAuthorisationScheme::NewLC(TUid::Uid(KTOCSP_UID), *iUnifiedCertStore);
       
   681 		iParams->AddAuthorisationSchemeL(scheme);
       
   682 		CleanupStack::Pop(); // scheme, now owned by client
       
   683 		}
       
   684 	
       
   685 	if (iUseCADelegateAuthorisation)
       
   686 		{
       
   687 		COCSPDelegateAuthorisationScheme* schemeDel =
       
   688 			COCSPDelegateAuthorisationScheme::NewLC(*iUnifiedCertStore);
       
   689 		iParams->AddAuthorisationSchemeL(schemeDel);
       
   690 		CleanupStack::Pop(schemeDel); // scheme, now owned by client		
       
   691 		}
       
   692 	
       
   693 	if (iUseCADirectAuthorisation)
       
   694 		{
       
   695 		COCSPCaDirectAuthorisationScheme* schemeCad =
       
   696 			COCSPCaDirectAuthorisationScheme::NewLC();
       
   697 		iParams->AddAuthorisationSchemeL(schemeCad);
       
   698 		CleanupStack::Pop(schemeCad); // scheme, now owned by client		
       
   699 		}
       
   700 	}
       
   701 
       
   702 // Set filter parameters
       
   703 void CTOCSPEngine::DefineAndSetFilterParametersL()
       
   704 	{
       
   705 	TUid categoryUid = TUid::Uid(KFilterParametersCategoryUID);
       
   706 
       
   707 	// Define the parameters
       
   708 	RProperty::Define(categoryUid, KFilterParameterNumDelayResp, RProperty::EInt);
       
   709 	RProperty::Define(categoryUid, KFilterParameterCountDropResp, RProperty::EInt);
       
   710 	RProperty::Define(categoryUid, KFilterParameterCountCorruptHTTPDataHeader, RProperty::EInt);
       
   711 	RProperty::Define(categoryUid, KFilterParameterCountCorruptHTTPDataBodySizeLarge, RProperty::EInt);
       
   712 	RProperty::Define(categoryUid, KFilterParameterCountCorruptHTTPDataBodySizeSmall, RProperty::EInt);
       
   713 	RProperty::Define(categoryUid, KFilterParameterCountCorruptOCSPData, RProperty::EInt);
       
   714 	RProperty::Define(categoryUid, KFilterParameterCountInternalErrorResp, RProperty::EInt);
       
   715 	RProperty::Define(categoryUid, KFilterParameterCountTryLaterResp, RProperty::EInt);
       
   716 	RProperty::Define(categoryUid, KFilterParameterCountSigValidateFailure, RProperty::EInt);
       
   717 
       
   718 	// and Set them
       
   719 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterNumDelayResp, iNumDelayResp));
       
   720 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountDropResp, iCountDropResp));
       
   721 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountCorruptHTTPDataHeader, iCountCorruptHTTPDataHeader));
       
   722 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountCorruptHTTPDataBodySizeLarge, iCountCorruptHTTPDataBodySizeLarge));
       
   723 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountCorruptHTTPDataBodySizeSmall, iCountCorruptHTTPDataBodySizeSmall));
       
   724 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountCorruptOCSPData, iCountCorruptOCSPData));
       
   725 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountInternalErrorResp, iCountInternalErrorResp));
       
   726 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountTryLaterResp, iCountTryLaterResp));
       
   727 	User::LeaveIfError(RProperty::Set(categoryUid, KFilterParameterCountSigValidateFailure, iCountSigValidateFailure));
       
   728 	}
       
   729 
       
   730 void CTOCSPEngine::DeleteFilterParameters()
       
   731 	{
       
   732 	TUid categoryUid = TUid::Uid(KFilterParametersCategoryUID);
       
   733 	RProperty::Delete(categoryUid, KFilterParameterNumDelayResp);
       
   734 	RProperty::Delete(categoryUid, KFilterParameterCountDropResp);
       
   735 	RProperty::Delete(categoryUid, KFilterParameterCountCorruptHTTPDataHeader);
       
   736 	RProperty::Delete(categoryUid, KFilterParameterCountCorruptHTTPDataBodySizeLarge);
       
   737 	RProperty::Delete(categoryUid, KFilterParameterCountCorruptHTTPDataBodySizeSmall);
       
   738 	RProperty::Delete(categoryUid, KFilterParameterCountCorruptOCSPData);
       
   739 	RProperty::Delete(categoryUid, KFilterParameterCountInternalErrorResp);
       
   740 	RProperty::Delete(categoryUid, KFilterParameterCountTryLaterResp);
       
   741 	RProperty::Delete(categoryUid, KFilterParameterCountSigValidateFailure);
       
   742 	// Reset the params
       
   743 	iNumDelayResp = iCountDropResp = iCountCorruptHTTPDataHeader = iCountCorruptHTTPDataBodySizeLarge = 
       
   744 		iCountCorruptHTTPDataBodySizeSmall = iCountCorruptOCSPData = iCountInternalErrorResp = 
       
   745 		iCountTryLaterResp = iCountSigValidateFailure = 0;
       
   746 	}
       
   747 
       
   748 void CTOCSPEngine::SetCancelTime(TInt aTime)
       
   749 	{
       
   750 	iCancelTime = aTime;
       
   751 	}
       
   752 
       
   753 void CTOCSPEngine::Check(TRequestStatus& aStatus)
       
   754 	{
       
   755     TRAPD(err, DoCheckL(aStatus));
       
   756     if (err != KErrNone)
       
   757         {
       
   758         Cancel();
       
   759         TRequestStatus* status = &aStatus;
       
   760         User::RequestComplete(status, err);
       
   761         }
       
   762     }
       
   763 
       
   764 void CTOCSPEngine::DoCheckL(TRequestStatus& aStatus)
       
   765  	{
       
   766 	iOriginalRequestStatus = &aStatus;
       
   767 	aStatus = KRequestPending;
       
   768 	iState = EChecking;
       
   769 
       
   770 	PrepareAuthorisationL();
       
   771 
       
   772 	// Set filter parameters
       
   773 	DefineAndSetFilterParametersL();
       
   774 
       
   775 	if (iVerbose)
       
   776 		{
       
   777 		iLog.LogL(_L("Checking...\n"), ETrue);
       
   778 		}
       
   779 
       
   780 	iClient = COCSPClient::NewL(iParams);
       
   781 	iParams = NULL; // Client takes ownership
       
   782 
       
   783 	// Setup cancellation timer
       
   784 	if (iCancelTime)
       
   785 		{
       
   786 		iTimer->After(iCancelTime * KTimeMilliToMicro);
       
   787 		}
       
   788 	iClient->Check(iStatus);
       
   789 	SetActive();
       
   790  	}
       
   791 
       
   792 void CTOCSPEngine::LogValidationL(const TOCSPOutcome& aOutcome) const
       
   793 	{
       
   794 	if (iVerbose)
       
   795 		{
       
   796 		iLog.LogL(_L("Validation complete:\n  status == "));
       
   797 		iLog.LogL(TranslateStatusL(aOutcome.iStatus));
       
   798 	
       
   799 		// Output summary result
       
   800 		iLog.LogL(_L("\n  summary result == "));
       
   801 		iLog.LogL(TranslateResultL(aOutcome.iResult));
       
   802 		iLog.NewLineL();
       
   803 		}
       
   804 	}
       
   805 
       
   806 
       
   807 TPtrC CTOCSPEngine::TranslateStatusL(OCSP::TStatus aStatus)
       
   808 	{
       
   809 	switch ((TInt) aStatus)
       
   810 		{
       
   811 		case OCSP::ETransportError:
       
   812 			return _L("Transport error");
       
   813 		case OCSP::ETimeOut:
       
   814 			return _L("Request timedout");
       
   815 		case OCSP::EClientInternalError:
       
   816 			return _L("Client internal error");
       
   817 		case OCSP::ENoServerSpecified:
       
   818 			return _L("No server specified");
       
   819 		case OCSP::EInvalidURI:
       
   820 			return _L("Invalid URI");
       
   821 		case OCSP::EMalformedResponse:
       
   822 			return _L("Malformed response");
       
   823 		case OCSP::EUnknownResponseType:
       
   824 			return _L("Unknown response type");
       
   825 		case OCSP::EUnknownCriticalExtension:
       
   826 			return _L("Unknown critical extension");
       
   827 		case OCSP::EMalformedRequest:
       
   828 			return _L("Server: Malformed request");
       
   829 		case OCSP::EServerInternalError:
       
   830 			return _L("Server: Internal error");
       
   831 		case OCSP::ETryLater:
       
   832 			return _L("Server: Try later");
       
   833 		case OCSP::ESignatureRequired:
       
   834 			return _L("Server: Signature required");
       
   835 		case OCSP::EClientUnauthorised:
       
   836 			return _L("Server: Client unauthorised");
       
   837 		case OCSP::EMissingCertificates:
       
   838 			return _L("Missing certificates");
       
   839 		case OCSP::EResponseSignatureValidationFailure:
       
   840 			return _L("Response signature validation failure");
       
   841 		case OCSP::EThisUpdateTooLate:
       
   842 			return _L("Time error: This update too late");
       
   843 		case OCSP::EThisUpdateTooEarly:
       
   844 			return _L("Time error: This update too early");
       
   845 		case OCSP::ENextUpdateTooEarly:
       
   846 			return _L("Time error: Next update too early");
       
   847 		case OCSP::ECertificateNotValidAtValidationTime:
       
   848 			return _L("Time error: Not valid at validation time");
       
   849 		case OCSP::ENonceMismatch:
       
   850 			return _L("Nonce mismatch");			
       
   851 		case OCSP::EMissingNonce:
       
   852 			return _L("Missing nonce");
       
   853 		case OCSP::EValid:
       
   854 			return _L("Valid");
       
   855 		case TOCSP::ETooManyTransactions:
       
   856 			return _L("(test) Too many transactions");
       
   857 		case TOCSP::EURIMismatch:
       
   858 			return _L("(test) URI mismatch");
       
   859 		case TOCSP::ERequestMismatch:
       
   860 			return _L("(test) Request mismatch");
       
   861 		default:
       
   862 			return _L("Unknown");
       
   863 		}
       
   864 	}
       
   865 
       
   866 
       
   867 TPtrC CTOCSPEngine::TranslateResultL(OCSP::TResult aResult)
       
   868 	{
       
   869 	switch (aResult)
       
   870 		{
       
   871 		case OCSP::EGood:
       
   872 			return _L("Good");
       
   873 		case OCSP::ERevoked:
       
   874 			return _L("Revoked");
       
   875 		case OCSP::EUnknown:
       
   876 			return _L("Unknown");
       
   877 		default:
       
   878 			return _L("Unknown");
       
   879 		}
       
   880 	}
       
   881 
       
   882 
       
   883 HBufC8* CTOCSPEngine::ReadDataL(RFs& session, const TDesC& aFileName) const
       
   884 	{
       
   885 	RFile file;
       
   886 	User::LeaveIfError(file.Open(session, aFileName, EFileRead | EFileShareReadersOnly));
       
   887 	CleanupClosePushL(file);
       
   888 
       
   889 	TInt size = 0;
       
   890 	User::LeaveIfError(file.Size(size));
       
   891 
       
   892 	HBufC8* data = HBufC8::NewLC(size);
       
   893 	TPtr8 dataPtr = data->Des();
       
   894 	User::LeaveIfError(file.Read(dataPtr));
       
   895 
       
   896 	CleanupStack::Pop(data);
       
   897 	CleanupStack::PopAndDestroy(); // Close file;
       
   898 	
       
   899 	return data;
       
   900 	}
       
   901 
       
   902 
       
   903 void CTOCSPEngine::LogRequestL(const TDesC& aFilename)
       
   904     {
       
   905 	delete iRequestLog;
       
   906 	iRequestLog = NULL;
       
   907 
       
   908 	iRequestLog = aFilename.AllocL();
       
   909 	}
       
   910 
       
   911 
       
   912 void CTOCSPEngine::LogResponseL(const TDesC& aFilename)
       
   913     {
       
   914 	RFs fs;
       
   915 	User::LeaveIfError(fs.Connect());
       
   916 	CleanupClosePushL(fs);
       
   917 
       
   918 	TInt err = fs.MkDirAll(aFilename);
       
   919 	if (err != KErrAlreadyExists)
       
   920 		{
       
   921 		User::LeaveIfError(err);
       
   922 		}
       
   923 
       
   924 	RFile file;
       
   925 	User::LeaveIfError(file.Replace(fs, aFilename, EFileWrite));
       
   926 	CleanupClosePushL(file);
       
   927 
       
   928 	RFileWriteStream writeStream(file);
       
   929 	CleanupClosePushL(writeStream);
       
   930 
       
   931 	writeStream.WriteUint32L(iClient->TransactionCount());
       
   932 
       
   933 	for (int i = 0 ; i < iClient->TransactionCount() ; ++i)
       
   934 		{
       
   935 		const COCSPResponse* response = iClient->Response(i);
       
   936 		if (response)
       
   937 			{
       
   938 			const TPtrC8 data = response->Encoding();
       
   939 			writeStream.WriteUint32L(data.Length());
       
   940 			writeStream.WriteL(data);
       
   941 			}
       
   942 		else
       
   943 			{
       
   944 			writeStream.WriteUint32L(0);
       
   945 			}
       
   946 		}
       
   947 
       
   948 	CleanupStack::PopAndDestroy(3); // writeStream, file, fs
       
   949     }
       
   950 
       
   951 
       
   952 void CTOCSPEngine::SetVerbose(TBool aVerbose)
       
   953 	{
       
   954 	iVerbose = aVerbose;
       
   955 	}
       
   956 
       
   957 TBool CTOCSPEngine::TestSummaryL(OCSP::TResult aExpected)
       
   958 	{
       
   959 	TBool result = iClient->SummaryResult() == aExpected;
       
   960 
       
   961 	if (iVerbose && !result)
       
   962 		{
       
   963 		iLog.LogL(_L("Summary result fail: expected "));
       
   964 		iLog.LogL(aExpected);
       
   965 		iLog.NewLineL();
       
   966 		}
       
   967 
       
   968 	return result;
       
   969 	}
       
   970 
       
   971 TBool CTOCSPEngine::TestOutcomeL(TInt aIndex, const TOCSPOutcome& aExpected)
       
   972 	{
       
   973 	TBool result = EFalse;
       
   974 	// This assumes one-transaction-per-certificate behaviour
       
   975 	if(iClient)
       
   976 		{
       
   977 		result = iClient->Outcome(aIndex) == aExpected;
       
   978 		}
       
   979 
       
   980 	if (iVerbose && !result)
       
   981 		{
       
   982 		iLog.LogL(_L("Outcome result fail for cert "));
       
   983 		iLog.LogL(aIndex);
       
   984 		iLog.LogL(_L(":\n"));
       
   985 		//iLog.LogL(_L("Expected Result:\n"));
       
   986 		iLog.LogL(_L("Expected Status == "));
       
   987 		iLog.LogL(TranslateStatusL(aExpected.iStatus));
       
   988 		iLog.NewLineL();
       
   989 		iLog.LogL(_L("Expected Result == "));
       
   990 		iLog.LogL(TranslateResultL(aExpected.iResult));
       
   991 		iLog.NewLineL();
       
   992 		}
       
   993 
       
   994 	return result;
       
   995 	}
       
   996 
       
   997 void CTOCSPEngine::SetReponderCertCheck()
       
   998 	{
       
   999 	iParams->SetOCSPCheckForResponderCert(ETrue);
       
  1000 	}
       
  1001 
       
  1002 void CTOCSPEngine::AddCertToStore(const TDesC& aCertFileName, const TDesC& aLabel, TCertificateOwnerType aCertType, TRequestStatus& aStatus)
       
  1003 	{
       
  1004 	iOriginalRequestStatus = &aStatus;
       
  1005 	aStatus = KRequestPending;
       
  1006 	iState = EAddingCert;
       
  1007 	
       
  1008 	iCert = aCertFileName;
       
  1009 	iLabel = aLabel;	
       
  1010 	
       
  1011 	iCertUtils->AddCert(iLabel, EX509Certificate, aCertType, KTOCSP_UID,
       
  1012 						KNullDesC, iCert, *iUnifiedCertStore, iStatus);		
       
  1013 	
       
  1014 	SetActive();
       
  1015 	}
       
  1016 
       
  1017 TBool CTOCSPEngine::TestTransportL(TInt aRetryCountNum, const TDesC& aExpectedHttpMethod, 
       
  1018 		TInt aExpectedRespTimeMin, TInt aExpectedRespTimeMax)
       
  1019 	{
       
  1020 	// This assumes one-tranaction-per-certificate behaviour
       
  1021 	// This also assumes test case includes only certificate revocation check request (which 
       
  1022 	// means CHECKRESPONDERCERT command cannot be used with this)
       
  1023 	// Ensure we have read the entry from the transport log
       
  1024 	TBool result = ETrue;
       
  1025 	if (iTransportLog.Count() < (aRetryCountNum + 1))
       
  1026 		{
       
  1027 		if (iVerbose)
       
  1028 			{
       
  1029 			iLog.LogL(_L("Transport filter log contains insufficient entries: "));
       
  1030 			iLog.LogL(_L("\n  Expected number of entries: "));
       
  1031 			iLog.LogL(aRetryCountNum + 1);
       
  1032 			iLog.LogL(_L("\n  Actual entries: "));
       
  1033 			iLog.LogL(iTransportLog.Count());
       
  1034 			iLog.NewLineL();
       
  1035 			}
       
  1036 		result = EFalse;
       
  1037 		}
       
  1038 
       
  1039 	TTransportLog& logEntry = iTransportLog[aRetryCountNum];
       
  1040 	// Convert to 8-bit
       
  1041 	RBuf8 expectedMethod;
       
  1042 	expectedMethod.CreateL(aExpectedHttpMethod.Length());
       
  1043 	CleanupClosePushL(expectedMethod);
       
  1044 	expectedMethod.Copy(aExpectedHttpMethod);
       
  1045 	expectedMethod.UpperCase();
       
  1046 	if (expectedMethod != logEntry.iHttpMethod)
       
  1047 		{
       
  1048 		if (iVerbose)
       
  1049 			{
       
  1050 			iLog.LogL(_L("Transport outcome result failed for send number: "));
       
  1051 			iLog.LogL(aRetryCountNum);
       
  1052 			iLog.LogL(_L("\n  Expected method: "));
       
  1053 			iLog.LogL(expectedMethod);
       
  1054 			iLog.LogL(_L("\n  Got method: "));
       
  1055 			iLog.LogL(logEntry.iHttpMethod);
       
  1056 			iLog.NewLineL();
       
  1057 			}
       
  1058 		result = EFalse;
       
  1059 		}
       
  1060 	CleanupStack::PopAndDestroy(&expectedMethod);
       
  1061 
       
  1062 	// Test the range of response time
       
  1063 	if (aExpectedRespTimeMin > logEntry.iTransDurationMs || aExpectedRespTimeMax < logEntry.iTransDurationMs)
       
  1064 		{
       
  1065 		if (iVerbose)
       
  1066 			{
       
  1067 			iLog.LogL(_L("Transport outcome result failed for send number: "));
       
  1068 			iLog.LogL(aRetryCountNum);
       
  1069 			iLog.LogL(_L("\n  Expected response time range (ms): "));
       
  1070 			iLog.LogL(aExpectedRespTimeMin);
       
  1071 			iLog.LogL(_L(" to "));
       
  1072 			iLog.LogL(aExpectedRespTimeMax);
       
  1073 			iLog.LogL(_L("\n  Actual response time (ms): "));
       
  1074 			iLog.LogL(logEntry.iTransDurationMs);
       
  1075 			iLog.NewLineL();
       
  1076 			}
       
  1077 		result = EFalse;
       
  1078 		}
       
  1079 	else if (iVerbose)
       
  1080 		{
       
  1081 		iLog.LogL(_L("Send number: "));
       
  1082 		iLog.LogL(aRetryCountNum);
       
  1083 		iLog.LogL(_L(" Response duration(ms): "));
       
  1084 		iLog.LogL(logEntry.iTransDurationMs);
       
  1085 		iLog.NewLineL();
       
  1086 		}
       
  1087 
       
  1088 	return result;
       
  1089 	}
       
  1090 
       
  1091 TBool CTOCSPEngine::TestTransportRetryL(TInt aRetryCount)
       
  1092 	{
       
  1093 	// This assumes one-tranaction-per-certificate behaviour
       
  1094 	// This also assumes test case includes only certificate revocation check request (which means 
       
  1095 	// CHECKRESPONDERCERT command cannot be used with this)
       
  1096 	// Check the number of retries
       
  1097 	TBool result = ETrue;
       
  1098 	if (iTransportLog.Count() != aRetryCount)
       
  1099 		{
       
  1100 		if (iVerbose)
       
  1101 			{
       
  1102 			iLog.LogL(_L("Transport retry outcome result failed:"));
       
  1103 			iLog.LogL(_L("\n  Expected number of retries: "));
       
  1104 			iLog.LogL(aRetryCount);
       
  1105 			iLog.LogL(_L("\n  Actual retries: "));
       
  1106 			iLog.LogL(iTransportLog.Count());
       
  1107 			iLog.NewLineL();
       
  1108 			}
       
  1109 		result = EFalse;
       
  1110 		}
       
  1111 
       
  1112 	return result;
       
  1113 	}
       
  1114 
       
  1115 void CTOCSPEngine::SetCheckCertsWithAiaOnly(TBool aCheckCertsWithAiaOnly)
       
  1116 	{
       
  1117 	iParams->SetCheckCertsWithAiaOnly(aCheckCertsWithAiaOnly);
       
  1118 	}
       
  1119 
       
  1120 void CTOCSPEngine::SetUseAIA(TBool aUseAIA)
       
  1121 	{
       
  1122 	iParams->SetUseAIA(aUseAIA);
       
  1123 	}