applayerpluginsandutils/httptransportplugins/httptransporthandler/csecuresocketcontroller.cpp
branchRCL_3
changeset 53 c59bddbfd7b9
parent 40 a0da872af3fa
equal deleted inserted replaced
40:a0da872af3fa 53:c59bddbfd7b9
    14 //
    14 //
    15 
    15 
    16 // User includes
    16 // User includes
    17 #include "csecuresocketcontroller.h"
    17 #include "csecuresocketcontroller.h"
    18 #include "thttptrlayerpanic.h"
    18 #include "thttptrlayerpanic.h"
    19 #include "chttptransportlayer.h"
       
    20 #include <x509certext.h>
    19 #include <x509certext.h>
    21 #include <securesocket.h>
    20 #include <securesocket.h>
    22 #include <ssl_internal.h>
    21 #include <ssl_internal.h>
    23 #include <featdiscovery.h>
    22 
    24 #include <featureuids.h>
       
    25 
    23 
    26 CSecureSocketController* CSecureSocketController::NewL(TAny* aInitParams)
    24 CSecureSocketController* CSecureSocketController::NewL(TAny* aInitParams)
    27 /**
    25 /**
    28 	Factory constructor.
    26 	Factory constructor.
    29 	@param		aSocket 			The socket that requires a secure connection,
    27 	@param		aSocket 			The socket that requires a secure connection,
    73 							against certificates.
    71 							against certificates.
    74 */
    72 */
    75 	{
    73 	{
    76 	// Create the secure layer
    74 	// Create the secure layer
    77 	if( iTlsSocket == NULL )
    75 	if( iTlsSocket == NULL )
    78 		iTlsSocket = CSecureSocket::NewL(iSocket, aProtocolVersion);
    76 		{
       
    77         iTlsSocket = CSecureSocket::NewL(iSocket, aProtocolVersion);
       
    78         }
       
    79 	// Get the security preferences, dialog prompt and security policy
       
    80 	TBool dialogPref = ETrue;
    79 	MSecurityPolicy* securityPolicy = NULL;
    81 	MSecurityPolicy* securityPolicy = NULL;
    80 	
    82 	iCommsInfoProvider.SecurityPreferences(dialogPref, securityPolicy);
    81 	TBool allowUntrustedCertificates = EFalse;
       
    82 
    83 
    83 	allowUntrustedCertificates = CFeatureDiscovery::IsFeatureSupportedL(NFeature::KFeatureIdFfHttpAllowUntrustedCertificates);
    84 	// Dialog preferences
    84 	// Get the security preferences, dialog prompt and security policy
    85 	if( !dialogPref )
    85 	if( allowUntrustedCertificates )
    86 		User::LeaveIfError(iTlsSocket->SetDialogMode(EDialogModeUnattended));
    86 		{
       
    87 		TInt dialogPref( CHttpTransportLayer::ETHttpDialogModeAttended );
       
    88 		iCommsInfoProvider.SecurityPreferences(dialogPref, securityPolicy);
       
    89 		if ( CHttpTransportLayer::ETHttpDialogModeAllowAutomatic == dialogPref )
       
    90             {
       
    91             User::LeaveIfError(iTlsSocket->SetDialogMode(EDialogModeAllowAutomatic));
       
    92             }
       
    93 		}
       
    94 	else
       
    95 		{
       
    96 		TBool dialogPref = ETrue;
       
    97 		iCommsInfoProvider.SecurityPreferences(dialogPref, securityPolicy);
       
    98 		if( !dialogPref )
       
    99             User::LeaveIfError(iTlsSocket->SetDialogMode(EDialogModeUnattended));
       
   100 		}
       
   101 
    87 
   102 	// Security policy preferences
    88 	// Security policy preferences
   103 	if( securityPolicy )
    89 	if( securityPolicy )
   104 		{
    90 		{
   105 		TPtrC8 ciphers = securityPolicy->GetTlsCipherSuites();
    91 		TPtrC8 ciphers = securityPolicy->GetTlsCipherSuites();