2003-07-22 05:17:52 +02:00
|
|
|
/*
|
|
|
|
* Wininet
|
|
|
|
*
|
|
|
|
* Copyright 2003 Mike McCormack for CodeWeavers Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-22 05:17:52 +02:00
|
|
|
*/
|
|
|
|
|
2015-02-13 12:12:29 +01:00
|
|
|
#include "ws2tcpip.h"
|
2008-12-09 11:33:25 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-07-22 05:17:52 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wininet.h"
|
|
|
|
#include "winnetwk.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#define NO_SHLWAPI_STREAM
|
|
|
|
#include "shlwapi.h"
|
2013-02-26 15:43:44 +01:00
|
|
|
#include "cryptuiapi.h"
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
#include "internet.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "resource.h"
|
|
|
|
|
2010-12-19 21:34:28 +01:00
|
|
|
#define MAX_STRING_LEN 1024
|
|
|
|
|
2003-07-22 05:17:52 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wininet);
|
|
|
|
|
|
|
|
struct WININET_ErrorDlgParams
|
|
|
|
{
|
2012-06-07 15:41:08 +02:00
|
|
|
http_request_t *req;
|
2003-07-22 05:17:52 +02:00
|
|
|
HWND hWnd;
|
|
|
|
DWORD dwError;
|
|
|
|
DWORD dwFlags;
|
|
|
|
LPVOID* lppvData;
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WININET_GetAuthRealm
|
|
|
|
*
|
|
|
|
* Determine the name of the (basic) Authentication realm
|
|
|
|
*/
|
2009-07-23 12:05:25 +02:00
|
|
|
static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPWSTR szBuf, DWORD sz, BOOL proxy )
|
2003-07-22 05:17:52 +02:00
|
|
|
{
|
2004-03-25 06:29:47 +01:00
|
|
|
LPWSTR p, q;
|
2009-07-23 12:05:25 +02:00
|
|
|
DWORD index, query;
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR szRealm[] = { 'r','e','a','l','m','=',0 };
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2009-07-23 12:05:25 +02:00
|
|
|
if (proxy)
|
|
|
|
query = HTTP_QUERY_PROXY_AUTHENTICATE;
|
|
|
|
else
|
|
|
|
query = HTTP_QUERY_WWW_AUTHENTICATE;
|
|
|
|
|
|
|
|
/* extract the Realm from the response and show it */
|
2003-07-22 05:17:52 +02:00
|
|
|
index = 0;
|
2009-07-23 12:05:25 +02:00
|
|
|
if( !HttpQueryInfoW( hRequest, query, szBuf, &sz, &index) )
|
2003-07-22 05:17:52 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: maybe we should check that we're
|
|
|
|
* dealing with 'Basic' Authentication
|
|
|
|
*/
|
2004-03-25 06:29:47 +01:00
|
|
|
p = strchrW( szBuf, ' ' );
|
2006-05-24 12:28:26 +02:00
|
|
|
if( !p || strncmpW( p+1, szRealm, strlenW(szRealm) ) )
|
2003-07-22 05:17:52 +02:00
|
|
|
{
|
2009-07-23 12:05:25 +02:00
|
|
|
ERR("response wrong? (%s)\n", debugstr_w(szBuf));
|
2006-05-24 12:28:26 +02:00
|
|
|
return FALSE;
|
2003-07-22 05:17:52 +02:00
|
|
|
}
|
|
|
|
|
2006-05-24 12:28:26 +02:00
|
|
|
/* remove quotes */
|
|
|
|
p += 7;
|
|
|
|
if( *p == '"' )
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
q = strrchrW( p, '"' );
|
|
|
|
if( q )
|
|
|
|
*q = 0;
|
|
|
|
}
|
2004-03-25 06:29:47 +01:00
|
|
|
strcpyW( szBuf, p );
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-11-15 14:34:41 +01:00
|
|
|
/* These two are not defined in the public headers */
|
|
|
|
extern DWORD WINAPI WNetCachePassword(LPSTR,WORD,LPSTR,WORD,BYTE,WORD);
|
|
|
|
extern DWORD WINAPI WNetGetCachedPassword(LPSTR,WORD,LPSTR,LPWORD,BYTE);
|
|
|
|
|
2003-07-22 05:17:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WININET_GetSetPassword
|
|
|
|
*/
|
2004-03-25 06:29:47 +01:00
|
|
|
static BOOL WININET_GetSetPassword( HWND hdlg, LPCWSTR szServer,
|
|
|
|
LPCWSTR szRealm, BOOL bSet )
|
2003-07-22 05:17:52 +02:00
|
|
|
{
|
2004-03-25 06:29:47 +01:00
|
|
|
WCHAR szResource[0x80], szUserPass[0x40];
|
|
|
|
LPWSTR p;
|
2003-07-22 05:17:52 +02:00
|
|
|
HWND hUserItem, hPassItem;
|
|
|
|
DWORD r, dwMagic = 19;
|
2004-03-25 06:29:47 +01:00
|
|
|
UINT r_len, u_len;
|
2003-07-22 05:17:52 +02:00
|
|
|
WORD sz;
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR szColon[] = { ':',0 };
|
|
|
|
static const WCHAR szbs[] = { '/', 0 };
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
hUserItem = GetDlgItem( hdlg, IDC_USERNAME );
|
|
|
|
hPassItem = GetDlgItem( hdlg, IDC_PASSWORD );
|
|
|
|
|
|
|
|
/* now try fetch the username and password */
|
2004-03-25 06:29:47 +01:00
|
|
|
lstrcpyW( szResource, szServer);
|
|
|
|
lstrcatW( szResource, szbs);
|
|
|
|
lstrcatW( szResource, szRealm);
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2004-03-25 06:29:47 +01:00
|
|
|
/*
|
|
|
|
* WNetCachePassword is only concerned with the length
|
|
|
|
* of the data stored (which we tell it) and it does
|
|
|
|
* not use strlen() internally so we can add WCHAR data
|
|
|
|
* instead of ASCII data and get it back the same way.
|
|
|
|
*/
|
2003-07-22 05:17:52 +02:00
|
|
|
if( bSet )
|
|
|
|
{
|
|
|
|
szUserPass[0] = 0;
|
2018-09-20 19:13:59 +02:00
|
|
|
GetWindowTextW( hUserItem, szUserPass, ARRAY_SIZE( szUserPass ) - 1 );
|
2004-03-25 06:29:47 +01:00
|
|
|
lstrcatW(szUserPass, szColon);
|
|
|
|
u_len = strlenW( szUserPass );
|
2018-09-20 19:13:59 +02:00
|
|
|
GetWindowTextW( hPassItem, szUserPass+u_len, ARRAY_SIZE( szUserPass ) - u_len );
|
2004-03-25 06:29:47 +01:00
|
|
|
|
|
|
|
r_len = (strlenW( szResource ) + 1)*sizeof(WCHAR);
|
|
|
|
u_len = (strlenW( szUserPass ) + 1)*sizeof(WCHAR);
|
|
|
|
r = WNetCachePassword( (CHAR*)szResource, r_len,
|
|
|
|
(CHAR*)szUserPass, u_len, dwMagic, 0 );
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
return ( r == WN_SUCCESS );
|
|
|
|
}
|
|
|
|
|
|
|
|
sz = sizeof szUserPass;
|
2004-03-25 06:29:47 +01:00
|
|
|
r_len = (strlenW( szResource ) + 1)*sizeof(WCHAR);
|
|
|
|
r = WNetGetCachedPassword( (CHAR*)szResource, r_len,
|
|
|
|
(CHAR*)szUserPass, &sz, dwMagic );
|
2003-07-22 05:17:52 +02:00
|
|
|
if( r != WN_SUCCESS )
|
|
|
|
return FALSE;
|
|
|
|
|
2004-03-25 06:29:47 +01:00
|
|
|
p = strchrW( szUserPass, ':' );
|
2003-07-22 05:17:52 +02:00
|
|
|
if( p )
|
|
|
|
{
|
|
|
|
*p = 0;
|
2004-03-25 06:29:47 +01:00
|
|
|
SetWindowTextW( hUserItem, szUserPass );
|
|
|
|
SetWindowTextW( hPassItem, p+1 );
|
2003-07-22 05:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2009-07-23 12:05:25 +02:00
|
|
|
* WININET_SetAuthorization
|
2003-07-22 05:17:52 +02:00
|
|
|
*/
|
2012-06-08 10:52:32 +02:00
|
|
|
static BOOL WININET_SetAuthorization( http_request_t *request, LPWSTR username,
|
2009-07-23 12:05:25 +02:00
|
|
|
LPWSTR password, BOOL proxy )
|
2003-07-22 05:17:52 +02:00
|
|
|
{
|
2012-06-08 10:52:32 +02:00
|
|
|
http_session_t *session = request->session;
|
2009-07-23 20:56:42 +02:00
|
|
|
LPWSTR p, q;
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2009-07-19 18:10:14 +02:00
|
|
|
p = heap_strdupW(username);
|
2003-07-22 05:17:52 +02:00
|
|
|
if( !p )
|
2012-06-08 10:52:32 +02:00
|
|
|
return FALSE;
|
2009-07-23 12:04:22 +02:00
|
|
|
|
2009-07-23 20:56:42 +02:00
|
|
|
q = heap_strdupW(password);
|
|
|
|
if( !q )
|
2009-07-23 12:05:25 +02:00
|
|
|
{
|
2012-10-30 20:07:25 +01:00
|
|
|
heap_free(p);
|
2012-06-08 10:52:32 +02:00
|
|
|
return FALSE;
|
2009-07-23 12:05:25 +02:00
|
|
|
}
|
2009-07-23 12:04:22 +02:00
|
|
|
|
2009-07-23 12:05:25 +02:00
|
|
|
if (proxy)
|
|
|
|
{
|
2011-03-01 20:02:14 +01:00
|
|
|
appinfo_t *hIC = session->appInfo;
|
2009-07-23 12:05:25 +02:00
|
|
|
|
2011-06-01 11:50:53 +02:00
|
|
|
heap_free(hIC->proxyUsername);
|
2011-03-01 20:00:49 +01:00
|
|
|
hIC->proxyUsername = p;
|
2009-07-23 12:05:25 +02:00
|
|
|
|
2011-06-01 11:50:53 +02:00
|
|
|
heap_free(hIC->proxyPassword);
|
2011-03-01 20:00:49 +01:00
|
|
|
hIC->proxyPassword = q;
|
2009-07-23 12:05:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-01 11:50:53 +02:00
|
|
|
heap_free(session->userName);
|
2011-03-01 20:02:14 +01:00
|
|
|
session->userName = p;
|
2009-07-23 12:05:25 +02:00
|
|
|
|
2011-06-01 11:50:53 +02:00
|
|
|
heap_free(session->password);
|
2011-03-01 20:02:14 +01:00
|
|
|
session->password = q;
|
2009-07-23 12:05:25 +02:00
|
|
|
}
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2012-06-08 10:52:32 +02:00
|
|
|
return TRUE;
|
2003-07-22 05:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WININET_ProxyPasswordDialog
|
|
|
|
*/
|
|
|
|
static INT_PTR WINAPI WININET_ProxyPasswordDialog(
|
|
|
|
HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
HWND hitem;
|
|
|
|
struct WININET_ErrorDlgParams *params;
|
2004-03-25 06:29:47 +01:00
|
|
|
WCHAR szRealm[0x80], szServer[0x80];
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
if( uMsg == WM_INITDIALOG )
|
|
|
|
{
|
|
|
|
TRACE("WM_INITDIALOG (%08lx)\n", lParam);
|
|
|
|
|
|
|
|
/* save the parameter list */
|
|
|
|
params = (struct WININET_ErrorDlgParams*) lParam;
|
2004-09-24 00:54:58 +02:00
|
|
|
SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
/* extract the Realm from the proxy response and show it */
|
2012-06-07 15:41:08 +02:00
|
|
|
if( WININET_GetAuthRealm( params->req->hdr.hInternet,
|
2018-09-20 19:13:59 +02:00
|
|
|
szRealm, ARRAY_SIZE( szRealm ), TRUE ) )
|
2003-07-22 05:17:52 +02:00
|
|
|
{
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_REALM );
|
2004-03-25 06:29:47 +01:00
|
|
|
SetWindowTextW( hitem, szRealm );
|
2003-07-22 05:17:52 +02:00
|
|
|
}
|
|
|
|
|
2012-06-08 10:51:58 +02:00
|
|
|
hitem = GetDlgItem( hdlg, IDC_PROXY );
|
|
|
|
SetWindowTextW( hitem, params->req->session->appInfo->proxy );
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
WININET_GetSetPassword( hdlg, szServer, szRealm, FALSE );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
params = (struct WININET_ErrorDlgParams*)
|
2004-09-24 00:54:58 +02:00
|
|
|
GetWindowLongPtrW( hdlg, GWLP_USERDATA );
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
switch( uMsg )
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
if( wParam == IDOK )
|
|
|
|
{
|
2004-03-25 06:29:47 +01:00
|
|
|
WCHAR username[0x20], password[0x20];
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
username[0] = 0;
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_USERNAME );
|
|
|
|
if( hitem )
|
2018-09-20 19:13:59 +02:00
|
|
|
GetWindowTextW( hitem, username, ARRAY_SIZE( username ));
|
|
|
|
|
2003-07-22 05:17:52 +02:00
|
|
|
password[0] = 0;
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_PASSWORD );
|
|
|
|
if( hitem )
|
2018-09-20 19:13:59 +02:00
|
|
|
GetWindowTextW( hitem, password, ARRAY_SIZE( password ));
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_SAVEPASSWORD );
|
|
|
|
if( hitem &&
|
2004-03-25 06:29:47 +01:00
|
|
|
SendMessageW( hitem, BM_GETSTATE, 0, 0 ) &&
|
2012-06-07 15:41:08 +02:00
|
|
|
WININET_GetAuthRealm( params->req->hdr.hInternet,
|
2018-09-20 19:13:59 +02:00
|
|
|
szRealm, ARRAY_SIZE( szRealm ), TRUE) )
|
2012-06-08 10:51:58 +02:00
|
|
|
WININET_GetSetPassword( hdlg, params->req->session->appInfo->proxy, szRealm, TRUE );
|
2012-06-08 10:52:32 +02:00
|
|
|
WININET_SetAuthorization( params->req, username, password, TRUE );
|
2003-07-22 05:17:52 +02:00
|
|
|
|
|
|
|
EndDialog( hdlg, ERROR_INTERNET_FORCE_RETRY );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if( wParam == IDCANCEL )
|
|
|
|
{
|
|
|
|
EndDialog( hdlg, 0 );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-07-23 12:05:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WININET_PasswordDialog
|
|
|
|
*/
|
|
|
|
static INT_PTR WINAPI WININET_PasswordDialog(
|
|
|
|
HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
HWND hitem;
|
|
|
|
struct WININET_ErrorDlgParams *params;
|
|
|
|
WCHAR szRealm[0x80], szServer[0x80];
|
|
|
|
|
|
|
|
if( uMsg == WM_INITDIALOG )
|
|
|
|
{
|
|
|
|
TRACE("WM_INITDIALOG (%08lx)\n", lParam);
|
|
|
|
|
|
|
|
/* save the parameter list */
|
|
|
|
params = (struct WININET_ErrorDlgParams*) lParam;
|
|
|
|
SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
|
|
|
|
|
|
|
|
/* extract the Realm from the response and show it */
|
2012-06-07 15:41:08 +02:00
|
|
|
if( WININET_GetAuthRealm( params->req->hdr.hInternet,
|
2018-09-20 19:13:59 +02:00
|
|
|
szRealm, ARRAY_SIZE( szRealm ), FALSE ) )
|
2009-07-23 12:05:58 +02:00
|
|
|
{
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_REALM );
|
|
|
|
SetWindowTextW( hitem, szRealm );
|
|
|
|
}
|
|
|
|
|
2012-06-08 10:52:12 +02:00
|
|
|
hitem = GetDlgItem( hdlg, IDC_SERVER );
|
|
|
|
SetWindowTextW( hitem, params->req->session->hostName );
|
2009-07-23 12:05:58 +02:00
|
|
|
|
|
|
|
WININET_GetSetPassword( hdlg, szServer, szRealm, FALSE );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
params = (struct WININET_ErrorDlgParams*)
|
|
|
|
GetWindowLongPtrW( hdlg, GWLP_USERDATA );
|
|
|
|
|
|
|
|
switch( uMsg )
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
if( wParam == IDOK )
|
|
|
|
{
|
|
|
|
WCHAR username[0x20], password[0x20];
|
|
|
|
|
|
|
|
username[0] = 0;
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_USERNAME );
|
|
|
|
if( hitem )
|
2018-09-20 19:13:59 +02:00
|
|
|
GetWindowTextW( hitem, username, ARRAY_SIZE( username ));
|
2009-07-23 12:05:58 +02:00
|
|
|
|
|
|
|
password[0] = 0;
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_PASSWORD );
|
|
|
|
if( hitem )
|
2018-09-20 19:13:59 +02:00
|
|
|
GetWindowTextW( hitem, password, ARRAY_SIZE( password ));
|
2009-07-23 12:05:58 +02:00
|
|
|
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_SAVEPASSWORD );
|
|
|
|
if( hitem &&
|
|
|
|
SendMessageW( hitem, BM_GETSTATE, 0, 0 ) &&
|
2012-06-07 15:41:08 +02:00
|
|
|
WININET_GetAuthRealm( params->req->hdr.hInternet,
|
2018-09-20 19:13:59 +02:00
|
|
|
szRealm, ARRAY_SIZE( szRealm ), FALSE ))
|
2009-07-23 12:05:58 +02:00
|
|
|
{
|
2012-06-08 10:52:12 +02:00
|
|
|
WININET_GetSetPassword( hdlg, params->req->session->hostName, szRealm, TRUE );
|
2009-07-23 12:05:58 +02:00
|
|
|
}
|
2012-06-08 10:52:32 +02:00
|
|
|
WININET_SetAuthorization( params->req, username, password, FALSE );
|
2009-07-23 12:05:58 +02:00
|
|
|
|
|
|
|
EndDialog( hdlg, ERROR_INTERNET_FORCE_RETRY );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if( wParam == IDCANCEL )
|
|
|
|
{
|
|
|
|
EndDialog( hdlg, 0 );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-19 21:34:28 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* WININET_InvalidCertificateDialog
|
|
|
|
*/
|
|
|
|
static INT_PTR WINAPI WININET_InvalidCertificateDialog(
|
|
|
|
HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
struct WININET_ErrorDlgParams *params;
|
|
|
|
HWND hitem;
|
|
|
|
WCHAR buf[1024];
|
|
|
|
|
|
|
|
if( uMsg == WM_INITDIALOG )
|
|
|
|
{
|
|
|
|
TRACE("WM_INITDIALOG (%08lx)\n", lParam);
|
|
|
|
|
|
|
|
/* save the parameter list */
|
|
|
|
params = (struct WININET_ErrorDlgParams*) lParam;
|
|
|
|
SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
|
|
|
|
|
|
|
|
switch( params->dwError )
|
|
|
|
{
|
|
|
|
case ERROR_INTERNET_INVALID_CA:
|
|
|
|
LoadStringW( WININET_hModule, IDS_CERT_CA_INVALID, buf, 1024 );
|
|
|
|
break;
|
|
|
|
case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
|
|
|
|
LoadStringW( WININET_hModule, IDS_CERT_DATE_INVALID, buf, 1024 );
|
|
|
|
break;
|
|
|
|
case ERROR_INTERNET_SEC_CERT_CN_INVALID:
|
|
|
|
LoadStringW( WININET_hModule, IDS_CERT_CN_INVALID, buf, 1024 );
|
|
|
|
break;
|
|
|
|
case ERROR_INTERNET_SEC_CERT_ERRORS:
|
|
|
|
/* FIXME: We should fetch information about the
|
|
|
|
* certificate here and show all the relevant errors.
|
|
|
|
*/
|
|
|
|
LoadStringW( WININET_hModule, IDS_CERT_ERRORS, buf, 1024 );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME( "No message for error %d\n", params->dwError );
|
|
|
|
buf[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
hitem = GetDlgItem( hdlg, IDC_CERT_ERROR );
|
|
|
|
SetWindowTextW( hitem, buf );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
params = (struct WININET_ErrorDlgParams*)
|
|
|
|
GetWindowLongPtrW( hdlg, GWLP_USERDATA );
|
|
|
|
|
|
|
|
switch( uMsg )
|
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
if( wParam == IDOK )
|
|
|
|
{
|
|
|
|
if( params->dwFlags & FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS )
|
|
|
|
{
|
2012-06-07 15:41:08 +02:00
|
|
|
http_request_t *req = params->req;
|
2010-12-19 21:34:28 +01:00
|
|
|
DWORD flags, size = sizeof(flags);
|
|
|
|
|
2012-06-07 15:41:08 +02:00
|
|
|
InternetQueryOptionW( req->hdr.hInternet, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size );
|
2010-12-19 21:34:28 +01:00
|
|
|
switch( params->dwError )
|
|
|
|
{
|
|
|
|
case ERROR_INTERNET_INVALID_CA:
|
|
|
|
flags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
|
|
|
|
break;
|
|
|
|
case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
|
|
|
|
flags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
|
|
|
|
break;
|
|
|
|
case ERROR_INTERNET_SEC_CERT_CN_INVALID:
|
|
|
|
flags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
|
|
|
|
break;
|
2012-06-07 15:41:35 +02:00
|
|
|
case ERROR_INTERNET_SEC_CERT_REV_FAILED:
|
|
|
|
flags |= SECURITY_FLAG_IGNORE_REVOCATION;
|
|
|
|
break;
|
2010-12-19 21:34:28 +01:00
|
|
|
case ERROR_INTERNET_SEC_CERT_ERRORS:
|
2012-06-01 16:42:09 +02:00
|
|
|
if(flags & _SECURITY_FLAG_CERT_REV_FAILED)
|
2012-06-07 15:40:31 +02:00
|
|
|
flags |= SECURITY_FLAG_IGNORE_REVOCATION;
|
|
|
|
if(flags & _SECURITY_FLAG_CERT_INVALID_CA)
|
2012-06-01 16:42:09 +02:00
|
|
|
flags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
|
|
|
|
if(flags & _SECURITY_FLAG_CERT_INVALID_CN)
|
|
|
|
flags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
|
|
|
|
if(flags & _SECURITY_FLAG_CERT_INVALID_DATE)
|
|
|
|
flags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
|
2010-12-19 21:34:28 +01:00
|
|
|
break;
|
|
|
|
}
|
2012-06-07 15:41:22 +02:00
|
|
|
/* FIXME: Use helper function */
|
|
|
|
flags |= SECURITY_FLAG_SECURE;
|
|
|
|
req->security_flags |= flags;
|
2013-12-11 10:48:41 +01:00
|
|
|
if(is_valid_netconn(req->netconn))
|
2012-06-07 15:41:22 +02:00
|
|
|
req->netconn->security_flags |= flags;
|
2010-12-19 21:34:28 +01:00
|
|
|
}
|
|
|
|
|
2015-11-23 00:17:18 +01:00
|
|
|
EndDialog( hdlg, ERROR_SUCCESS );
|
2010-12-19 21:34:28 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if( wParam == IDCANCEL )
|
|
|
|
{
|
|
|
|
TRACE("Pressed cancel.\n");
|
|
|
|
|
|
|
|
EndDialog( hdlg, ERROR_CANCELLED );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-07-22 05:17:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetErrorDlg
|
|
|
|
*/
|
|
|
|
DWORD WINAPI InternetErrorDlg(HWND hWnd, HINTERNET hRequest,
|
|
|
|
DWORD dwError, DWORD dwFlags, LPVOID* lppvData)
|
|
|
|
{
|
|
|
|
struct WININET_ErrorDlgParams params;
|
2012-06-07 15:41:08 +02:00
|
|
|
http_request_t *req = NULL;
|
|
|
|
DWORD res = ERROR_SUCCESS;
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2006-10-05 13:18:56 +02:00
|
|
|
TRACE("%p %p %d %08x %p\n", hWnd, hRequest, dwError, dwFlags, lppvData);
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2010-12-19 21:34:28 +01:00
|
|
|
if( !hWnd && !(dwFlags & FLAGS_ERROR_UI_FLAGS_NO_UI) )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2012-06-07 15:41:08 +02:00
|
|
|
if(hRequest) {
|
|
|
|
req = (http_request_t*)get_handle_object(hRequest);
|
|
|
|
if(!req)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
if(req->hdr.htype != WH_HHTTPREQ)
|
|
|
|
return ERROR_SUCCESS; /* Yes, that was tested */
|
|
|
|
}
|
|
|
|
|
|
|
|
params.req = req;
|
2003-07-22 05:17:52 +02:00
|
|
|
params.hWnd = hWnd;
|
|
|
|
params.dwError = dwError;
|
|
|
|
params.dwFlags = dwFlags;
|
|
|
|
params.lppvData = lppvData;
|
|
|
|
|
|
|
|
switch( dwError )
|
|
|
|
{
|
|
|
|
case ERROR_SUCCESS:
|
2012-06-07 15:41:08 +02:00
|
|
|
case ERROR_INTERNET_INCORRECT_PASSWORD: {
|
2009-07-23 12:05:58 +02:00
|
|
|
if( !dwError && !(dwFlags & FLAGS_ERROR_UI_FILTER_FOR_ERRORS ) )
|
2012-06-07 15:41:08 +02:00
|
|
|
break;
|
|
|
|
if(!req)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2012-06-08 10:52:42 +02:00
|
|
|
switch(req->status_code) {
|
2009-07-23 12:05:58 +02:00
|
|
|
case HTTP_STATUS_PROXY_AUTH_REQ:
|
2012-06-07 15:41:08 +02:00
|
|
|
res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_PROXYDLG ),
|
|
|
|
hWnd, WININET_ProxyPasswordDialog, (LPARAM) ¶ms );
|
|
|
|
break;
|
2009-07-23 12:05:58 +02:00
|
|
|
case HTTP_STATUS_DENIED:
|
2012-06-07 15:41:08 +02:00
|
|
|
res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_AUTHDLG ),
|
2009-07-23 12:05:58 +02:00
|
|
|
hWnd, WININET_PasswordDialog, (LPARAM) ¶ms );
|
2012-06-07 15:41:08 +02:00
|
|
|
break;
|
2009-07-23 12:05:58 +02:00
|
|
|
default:
|
2012-06-08 10:52:42 +02:00
|
|
|
WARN("unhandled status %u\n", req->status_code);
|
2009-07-23 12:05:58 +02:00
|
|
|
}
|
2012-06-07 15:41:08 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-12-19 21:34:28 +01:00
|
|
|
case ERROR_INTERNET_SEC_CERT_ERRORS:
|
|
|
|
case ERROR_INTERNET_SEC_CERT_CN_INVALID:
|
|
|
|
case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
|
|
|
|
case ERROR_INTERNET_INVALID_CA:
|
2012-06-07 15:41:35 +02:00
|
|
|
case ERROR_INTERNET_SEC_CERT_REV_FAILED:
|
2012-06-07 15:41:08 +02:00
|
|
|
if( dwFlags & FLAGS_ERROR_UI_FLAGS_NO_UI ) {
|
|
|
|
res = ERROR_CANCELLED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(!req)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2003-07-22 05:17:52 +02:00
|
|
|
|
2010-12-19 21:34:28 +01:00
|
|
|
if( dwFlags & ~FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS )
|
|
|
|
FIXME("%08x contains unsupported flags.\n", dwFlags);
|
|
|
|
|
2012-06-07 15:41:08 +02:00
|
|
|
res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_INVCERTDLG ),
|
|
|
|
hWnd, WININET_InvalidCertificateDialog, (LPARAM) ¶ms );
|
|
|
|
break;
|
2003-07-22 05:17:52 +02:00
|
|
|
case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
|
|
|
|
case ERROR_INTERNET_POST_IS_NON_SECURE:
|
2006-10-05 13:18:56 +02:00
|
|
|
FIXME("Need to display dialog for error %d\n", dwError);
|
2012-06-07 15:41:08 +02:00
|
|
|
res = ERROR_SUCCESS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = ERROR_NOT_SUPPORTED;
|
2003-07-22 05:17:52 +02:00
|
|
|
}
|
2010-12-19 21:34:28 +01:00
|
|
|
|
2012-06-07 15:41:08 +02:00
|
|
|
if(req)
|
|
|
|
WININET_Release(&req->hdr);
|
|
|
|
return res;
|
2003-07-22 05:17:52 +02:00
|
|
|
}
|
2013-02-26 15:43:44 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetShowSecurityInfoByURLA (@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetShowSecurityInfoByURLA(LPCSTR url, HWND window)
|
|
|
|
{
|
|
|
|
FIXME("stub: %s %p\n", url, window);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetShowSecurityInfoByURLW (@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetShowSecurityInfoByURLW(LPCWSTR url, HWND window)
|
|
|
|
{
|
|
|
|
FIXME("stub: %s %p\n", debugstr_w(url), window);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-03-28 05:20:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ParseX509EncodedCertificateForListBoxEntry (@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI ParseX509EncodedCertificateForListBoxEntry(LPBYTE cert, DWORD len, LPSTR szlistbox, LPDWORD listbox)
|
|
|
|
{
|
|
|
|
FIXME("stub: %p %d %s %p\n", cert, len, debugstr_a(szlistbox), listbox);
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-02-26 15:43:44 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* ShowX509EncodedCertificate (@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI ShowX509EncodedCertificate(HWND parent, LPBYTE cert, DWORD len)
|
|
|
|
{
|
|
|
|
PCCERT_CONTEXT certContext = CertCreateCertificateContext(X509_ASN_ENCODING,
|
|
|
|
cert, len);
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if (certContext)
|
|
|
|
{
|
|
|
|
CRYPTUI_VIEWCERTIFICATE_STRUCTW view;
|
|
|
|
|
|
|
|
memset(&view, 0, sizeof(view));
|
|
|
|
view.hwndParent = parent;
|
|
|
|
view.pCertContext = certContext;
|
|
|
|
if (CryptUIDlgViewCertificateW(&view, NULL))
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
else
|
|
|
|
ret = GetLastError();
|
|
|
|
CertFreeCertificateContext(certContext);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = GetLastError();
|
|
|
|
return ret;
|
|
|
|
}
|