CFtpClient::GetSecurityInformation Method  
 
BOOL GetSecurityInformation(
  LPSECURITYINFO lpSecurityInfo  
);

The GetSecurityInformation method returns security protocol, encryption and certificate information about the current client connection.

Parameters

lpSecurityInfo
A pointer to a SECURITYINFO structure which contains information about the current client connection. The dwSize member of this structure must be initialized to the size of the structure before passing the address of the structure to this method.

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

This method is used to obtain security related information about the current client connection to the server. It can be used to determine if a secure connection has been established, what security protocol was selected, and information about the server certificate. Note that a secure connection has not been established, the dwProtocol structure member will contain the value SECURITY_PROTOCOL_NONE.

Example

The following example notifies the user if the connection is secure or not:

SECURITYINFO securityInfo;
securityInfo.dwSize = sizeof(SECURITYINFO);

if (pClient->GetSecurityInformation(&securityInfo))
{
    if (securityInfo.dwProtocol == SECURITY_PROTOCOL_NONE)
    {
        MessageBox(NULL, _T("The connection is not secure"),
                         _T("Connection"), MB_OK);
    }
    else
    {
        if (securityInfo.dwCertStatus == SECURITY_CERTIFICATE_VALID)
        {
            MessageBox(NULL, _T("The connection is secure"),
                             _T("Connection"), MB_OK);
        }
        else
        {
            MessageBox(NULL, _T("The server certificate not valid"),
                             _T("Connection"), MB_OK);
        }
    }
}

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csftpv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

Connect, CreateSecurityCredentials, SECURITYINFO