CWebView::GetSecurityLevel Method  
 
BOOL GetSecurityLevel(
  LPDWORD lpdwLevel  
);

The GetSecurityLevel method returns the evaluated security level for the last navigation.

Parameters

lpdwLevel
A pointer to an unsigned integer which will contain the security level when the method returns. This parameter cannot be NULL.

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

The GetSecurityLevel method provides a simplified way to obtain the current security state of the page displayed in the browser. This value is an overall assessment of the page's security status and is primarily intended for use in user interface logic, such as whether to display a lock icon or warning indicator. The security level does not provide detailed diagnostic information; if your application requires additional context such as certificate details, protocol version, or specific security flags, you should call WebViewGetSecurityInfo instead.

The possible values returned in the lpdwLevel parameter correspond to the security level constants:

  • WEBVIEW_SECURITY_LEVEL_UNKNOWN: The security state could not be determined.
  • WEBVIEW_SECURITY_LEVEL_INSECURE: The page was retrieved over plain HTTP or the certificate is invalid.
  • WEBVIEW_SECURITY_LEVEL_WARNING: The page uses weak encryption or contains mixed content.
  • WEBVIEW_SECURITY_LEVEL_NEUTRAL: Local content or the browser is in a transitional state.
  • WEBVIEW_SECURITY_LEVEL_SECURE: The page was retrieved using HTTPS with a valid certificate.

Because the browser engine may revise the security assessment as additional resources are loaded, the level can change over the course of a navigation. For example, a page may initially appear secure, but once mixed content is detected the level will be downgraded to WEBVIEW_SECURITY_LEVEL_WARNING. Applications should refresh their indicators when they receive a WEBVIEW_EVENT_SECURITY_CHANGED notification or after navigation has completed.

The level values are ordered, with higher values indicating stronger security. Applications should avoid upgrading an observed level within the same navigation, since subsequent checks may legitimately lower the assessment.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib

See Also