| CWebView::GetSecurityInfo Method | |||||||||||
Parameters
Return Value
Remarks
Example// Map security level to text static LPCTSTR SecLevelToText(DWORD level) { switch (level) { case WEBVIEW_SECURITY_LEVEL_SECURE: return _T("SECURE"); case WEBVIEW_SECURITY_LEVEL_WARNING: return _T("WARNING"); case WEBVIEW_SECURITY_LEVEL_INSECURE: return _T("INSECURE"); case WEBVIEW_SECURITY_LEVEL_NEUTRAL: return _T("NEUTRAL"); default: return _T("UNKNOWN"); } } // Print a FILETIME value as YYYY-MM-DD HH:MM:SS static void PrintFileTime(LPCTSTR label, const FILETIME* pft) { if (!pft || (pft->dwLowDateTime == 0 && pft->dwHighDateTime == 0)) { _tprintf(_T("%s: (not available)\n"), label); return; } FILETIME lft = {0}; SYSTEMTIME st = {0}; if (FileTimeToLocalFileTime(pft, &lft) && FileTimeToSystemTime(&lft, &st)) { _tprintf(_T("%s: %04u-%02u-%02u %02u:%02u:%02u\n"), label, (unsigned)st.wYear, (unsigned)st.wMonth, (unsigned)st.wDay, (unsigned)st.wHour, (unsigned)st.wMinute, (unsigned)st.wSecond); } else { _tprintf(_T("%s: (conversion failed)\n"), label); } } // Build and print a readable flag list static void PrintSecurityFlags(DWORD dwFlags) { if (dwFlags == WEBVIEW_SECURITY_FLAG_NONE) { _tprintf(_T("Flags: NONE (0x%08lX)\n"), dwFlags); return; } _tprintf(_T("Flags: 0x%08lX"), dwFlags); if (dwFlags & WEBVIEW_SECURITY_FLAG_UNENCRYPTED) _tprintf(_T(" | UNENCRYPTED")); if (dwFlags & WEBVIEW_SECURITY_FLAG_INSECURE) _tprintf(_T(" | INSECURE")); if (dwFlags & WEBVIEW_SECURITY_FLAG_CERT_WEAK) _tprintf(_T(" | CERT_WEAK")); if (dwFlags & WEBVIEW_SECURITY_FLAG_CERT_ERROR) _tprintf(_T(" | CERT_ERROR")); if (dwFlags & WEBVIEW_SECURITY_FLAG_CERT_EXPIRED) _tprintf(_T(" | CERT_EXPIRED")); if (dwFlags & WEBVIEW_SECURITY_FLAG_UNSAFE) _tprintf(_T(" | UNSAFE")); _tprintf(_T("\n")); } // Query and display the current security info static void ShowSecurityInfo(CWebView *pWebView) { WEBVIEW_SECURITY_INFO secInfo = { 0 }; secInfo.dwSize = sizeof(secInfo); if (!pWebView->GetSecurityInfo(&secInfo)) { _tprintf(_T("GetSecurityInfo failed (Error 0x%lx)\n"), pWebView->GetLastError()); return; } _tprintf(_T("Security Level: %s\n"), SecLevelToText(secInfo.dwLevel)); PrintSecurityFlags(secInfo.dwFlags); if (secInfo.szProtocol[0]) _tprintf(_T("Protocol: %s\n"), secInfo.szProtocol); else _tprintf(_T("Protocol: (none)\n")); if (secInfo.szCipher[0]) _tprintf(_T("Cipher Suite: %s\n"), secInfo.szCipher); else _tprintf(_T("Cipher Suite: (none)\n")); if (secInfo.szSubject[0]) _tprintf(_T("Certificate Subject: %s\n"), secInfo.szSubject); else _tprintf(_T("Certificate Subject: (not available)\n")); if (secInfo.szIssuer[0]) _tprintf(_T("Certificate Issuer: %s\n"), secInfo.szIssuer); else _tprintf(_T("Certificate Issuer: (not available)\n")); PrintFileTime(_T("Valid From"), &secInfo.ftValidFrom); PrintFileTime(_T("Valid To "), &secInfo.ftValidTo); } Requirements
See Also |
|||||||||||
|
Copyright © 2026 Catalyst Development Corporation. All rights reserved. |
|||||||||||