15f12c8d7Swinesync #ifdef __REACTOS__
25f12c8d7Swinesync #include "precomp.h"
35f12c8d7Swinesync #else
4c2c66affSColin Finck /*
5c2c66affSColin Finck * Wininet
6c2c66affSColin Finck *
7c2c66affSColin Finck * Copyright 2003 Mike McCormack for CodeWeavers Inc.
8c2c66affSColin Finck *
9c2c66affSColin Finck * This library is free software; you can redistribute it and/or
10c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
11c2c66affSColin Finck * License as published by the Free Software Foundation; either
12c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
13c2c66affSColin Finck *
14c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
15c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
16c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17c2c66affSColin Finck * Lesser General Public License for more details.
18c2c66affSColin Finck *
19c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
20c2c66affSColin Finck * License along with this library; if not, write to the Free Software
21c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22c2c66affSColin Finck */
23c2c66affSColin Finck
24bc01cef0SAmine Khaldi #include "ws2tcpip.h"
25bc01cef0SAmine Khaldi
26bc01cef0SAmine Khaldi #include <stdarg.h>
27bc01cef0SAmine Khaldi
28bc01cef0SAmine Khaldi #include "windef.h"
29bc01cef0SAmine Khaldi #include "winbase.h"
30bc01cef0SAmine Khaldi #include "winuser.h"
31bc01cef0SAmine Khaldi #include "winreg.h"
32bc01cef0SAmine Khaldi #include "wininet.h"
33bc01cef0SAmine Khaldi #include "winnetwk.h"
34bc01cef0SAmine Khaldi #include "wine/debug.h"
35bc01cef0SAmine Khaldi #include "winerror.h"
36bc01cef0SAmine Khaldi #define NO_SHLWAPI_STREAM
37bc01cef0SAmine Khaldi #include "shlwapi.h"
38bc01cef0SAmine Khaldi #include "cryptuiapi.h"
39bc01cef0SAmine Khaldi
40c2c66affSColin Finck #include "internet.h"
41bc01cef0SAmine Khaldi #include "resource.h"
425f12c8d7Swinesync #endif /* defined(__REACTOS__) */
43c2c66affSColin Finck
44c2c66affSColin Finck #define MAX_STRING_LEN 1024
45c2c66affSColin Finck
46bc01cef0SAmine Khaldi WINE_DEFAULT_DEBUG_CHANNEL(wininet);
47bc01cef0SAmine Khaldi
48c2c66affSColin Finck struct WININET_ErrorDlgParams
49c2c66affSColin Finck {
50c2c66affSColin Finck http_request_t *req;
51c2c66affSColin Finck HWND hWnd;
52c2c66affSColin Finck DWORD dwError;
53c2c66affSColin Finck DWORD dwFlags;
54c2c66affSColin Finck LPVOID* lppvData;
55c2c66affSColin Finck };
56c2c66affSColin Finck
57c2c66affSColin Finck /***********************************************************************
58c2c66affSColin Finck * WININET_GetAuthRealm
59c2c66affSColin Finck *
60c2c66affSColin Finck * Determine the name of the (basic) Authentication realm
61c2c66affSColin Finck */
WININET_GetAuthRealm(HINTERNET hRequest,LPWSTR szBuf,DWORD sz,BOOL proxy)62c2c66affSColin Finck static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPWSTR szBuf, DWORD sz, BOOL proxy )
63c2c66affSColin Finck {
64c2c66affSColin Finck LPWSTR p, q;
65c2c66affSColin Finck DWORD index, query;
66c2c66affSColin Finck
67c2c66affSColin Finck if (proxy)
68c2c66affSColin Finck query = HTTP_QUERY_PROXY_AUTHENTICATE;
69c2c66affSColin Finck else
70c2c66affSColin Finck query = HTTP_QUERY_WWW_AUTHENTICATE;
71c2c66affSColin Finck
72c2c66affSColin Finck /* extract the Realm from the response and show it */
73c2c66affSColin Finck index = 0;
74c2c66affSColin Finck if( !HttpQueryInfoW( hRequest, query, szBuf, &sz, &index) )
75c2c66affSColin Finck return FALSE;
76c2c66affSColin Finck
77c2c66affSColin Finck /*
78c2c66affSColin Finck * FIXME: maybe we should check that we're
79c2c66affSColin Finck * dealing with 'Basic' Authentication
80c2c66affSColin Finck */
815f12c8d7Swinesync p = wcschr( szBuf, ' ' );
82*e152f78aSwinesync if( !p || wcsncmp( p+1, L"realm=", lstrlenW(L"realm=") ) )
83c2c66affSColin Finck {
84c2c66affSColin Finck ERR("response wrong? (%s)\n", debugstr_w(szBuf));
85c2c66affSColin Finck return FALSE;
86c2c66affSColin Finck }
87c2c66affSColin Finck
88c2c66affSColin Finck /* remove quotes */
89c2c66affSColin Finck p += 7;
90c2c66affSColin Finck if( *p == '"' )
91c2c66affSColin Finck {
92c2c66affSColin Finck p++;
935f12c8d7Swinesync q = wcsrchr( p, '"' );
94c2c66affSColin Finck if( q )
95c2c66affSColin Finck *q = 0;
96c2c66affSColin Finck }
975f12c8d7Swinesync lstrcpyW( szBuf, p );
98c2c66affSColin Finck
99c2c66affSColin Finck return TRUE;
100c2c66affSColin Finck }
101c2c66affSColin Finck
102c2c66affSColin Finck /* These two are not defined in the public headers */
103c2c66affSColin Finck extern DWORD WINAPI WNetCachePassword(LPSTR,WORD,LPSTR,WORD,BYTE,WORD);
104c2c66affSColin Finck extern DWORD WINAPI WNetGetCachedPassword(LPSTR,WORD,LPSTR,LPWORD,BYTE);
105c2c66affSColin Finck
106c2c66affSColin Finck /***********************************************************************
107c2c66affSColin Finck * WININET_GetSetPassword
108c2c66affSColin Finck */
WININET_GetSetPassword(HWND hdlg,LPCWSTR szServer,LPCWSTR szRealm,BOOL bSet)109c2c66affSColin Finck static BOOL WININET_GetSetPassword( HWND hdlg, LPCWSTR szServer,
110c2c66affSColin Finck LPCWSTR szRealm, BOOL bSet )
111c2c66affSColin Finck {
112c2c66affSColin Finck WCHAR szResource[0x80], szUserPass[0x40];
113c2c66affSColin Finck LPWSTR p;
114c2c66affSColin Finck HWND hUserItem, hPassItem;
115c2c66affSColin Finck DWORD r, dwMagic = 19;
116c2c66affSColin Finck UINT r_len, u_len;
117c2c66affSColin Finck WORD sz;
118c2c66affSColin Finck
119c2c66affSColin Finck hUserItem = GetDlgItem( hdlg, IDC_USERNAME );
120c2c66affSColin Finck hPassItem = GetDlgItem( hdlg, IDC_PASSWORD );
121c2c66affSColin Finck
122c2c66affSColin Finck /* now try fetch the username and password */
123c2c66affSColin Finck lstrcpyW( szResource, szServer);
124*e152f78aSwinesync lstrcatW( szResource, L"/");
125c2c66affSColin Finck lstrcatW( szResource, szRealm);
126c2c66affSColin Finck
127c2c66affSColin Finck /*
128c2c66affSColin Finck * WNetCachePassword is only concerned with the length
129c2c66affSColin Finck * of the data stored (which we tell it) and it does
130c2c66affSColin Finck * not use strlen() internally so we can add WCHAR data
131c2c66affSColin Finck * instead of ASCII data and get it back the same way.
132c2c66affSColin Finck */
133c2c66affSColin Finck if( bSet )
134c2c66affSColin Finck {
135c2c66affSColin Finck szUserPass[0] = 0;
136c239cdd4SAmine Khaldi GetWindowTextW( hUserItem, szUserPass, ARRAY_SIZE( szUserPass ) - 1 );
137*e152f78aSwinesync lstrcatW(szUserPass, L":");
1385f12c8d7Swinesync u_len = lstrlenW( szUserPass );
139c239cdd4SAmine Khaldi GetWindowTextW( hPassItem, szUserPass+u_len, ARRAY_SIZE( szUserPass ) - u_len );
140c2c66affSColin Finck
1415f12c8d7Swinesync r_len = (lstrlenW( szResource ) + 1)*sizeof(WCHAR);
1425f12c8d7Swinesync u_len = (lstrlenW( szUserPass ) + 1)*sizeof(WCHAR);
143c2c66affSColin Finck r = WNetCachePassword( (CHAR*)szResource, r_len,
144c2c66affSColin Finck (CHAR*)szUserPass, u_len, dwMagic, 0 );
145c2c66affSColin Finck
146c2c66affSColin Finck return ( r == WN_SUCCESS );
147c2c66affSColin Finck }
148c2c66affSColin Finck
149c2c66affSColin Finck sz = sizeof szUserPass;
1505f12c8d7Swinesync r_len = (lstrlenW( szResource ) + 1)*sizeof(WCHAR);
151c2c66affSColin Finck r = WNetGetCachedPassword( (CHAR*)szResource, r_len,
152c2c66affSColin Finck (CHAR*)szUserPass, &sz, dwMagic );
153c2c66affSColin Finck if( r != WN_SUCCESS )
154c2c66affSColin Finck return FALSE;
155c2c66affSColin Finck
1565f12c8d7Swinesync p = wcschr( szUserPass, ':' );
157c2c66affSColin Finck if( p )
158c2c66affSColin Finck {
159c2c66affSColin Finck *p = 0;
160c2c66affSColin Finck SetWindowTextW( hUserItem, szUserPass );
161c2c66affSColin Finck SetWindowTextW( hPassItem, p+1 );
162c2c66affSColin Finck }
163c2c66affSColin Finck
164c2c66affSColin Finck return TRUE;
165c2c66affSColin Finck }
166c2c66affSColin Finck
167c2c66affSColin Finck /***********************************************************************
168c2c66affSColin Finck * WININET_SetAuthorization
169c2c66affSColin Finck */
WININET_SetAuthorization(http_request_t * request,LPWSTR username,LPWSTR password,BOOL proxy)170c2c66affSColin Finck static BOOL WININET_SetAuthorization( http_request_t *request, LPWSTR username,
171c2c66affSColin Finck LPWSTR password, BOOL proxy )
172c2c66affSColin Finck {
173c2c66affSColin Finck http_session_t *session = request->session;
174c2c66affSColin Finck LPWSTR p, q;
175c2c66affSColin Finck
176c2c66affSColin Finck p = heap_strdupW(username);
177c2c66affSColin Finck if( !p )
178c2c66affSColin Finck return FALSE;
179c2c66affSColin Finck
180c2c66affSColin Finck q = heap_strdupW(password);
181c2c66affSColin Finck if( !q )
182c2c66affSColin Finck {
183c2c66affSColin Finck heap_free(p);
184c2c66affSColin Finck return FALSE;
185c2c66affSColin Finck }
186c2c66affSColin Finck
187c2c66affSColin Finck if (proxy)
188c2c66affSColin Finck {
189c2c66affSColin Finck appinfo_t *hIC = session->appInfo;
190c2c66affSColin Finck
191c2c66affSColin Finck heap_free(hIC->proxyUsername);
192c2c66affSColin Finck hIC->proxyUsername = p;
193c2c66affSColin Finck
194c2c66affSColin Finck heap_free(hIC->proxyPassword);
195c2c66affSColin Finck hIC->proxyPassword = q;
196c2c66affSColin Finck }
197c2c66affSColin Finck else
198c2c66affSColin Finck {
199c2c66affSColin Finck heap_free(session->userName);
200c2c66affSColin Finck session->userName = p;
201c2c66affSColin Finck
202c2c66affSColin Finck heap_free(session->password);
203c2c66affSColin Finck session->password = q;
204c2c66affSColin Finck }
205c2c66affSColin Finck
206c2c66affSColin Finck return TRUE;
207c2c66affSColin Finck }
208c2c66affSColin Finck
209c2c66affSColin Finck /***********************************************************************
210c2c66affSColin Finck * WININET_ProxyPasswordDialog
211c2c66affSColin Finck */
WININET_ProxyPasswordDialog(HWND hdlg,UINT uMsg,WPARAM wParam,LPARAM lParam)212c2c66affSColin Finck static INT_PTR WINAPI WININET_ProxyPasswordDialog(
213c2c66affSColin Finck HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
214c2c66affSColin Finck {
215c2c66affSColin Finck HWND hitem;
216c2c66affSColin Finck struct WININET_ErrorDlgParams *params;
217c239cdd4SAmine Khaldi WCHAR szRealm[0x80];
218c2c66affSColin Finck
219c2c66affSColin Finck if( uMsg == WM_INITDIALOG )
220c2c66affSColin Finck {
221c2c66affSColin Finck TRACE("WM_INITDIALOG (%08lx)\n", lParam);
222c2c66affSColin Finck
223c2c66affSColin Finck /* save the parameter list */
224c2c66affSColin Finck params = (struct WININET_ErrorDlgParams*) lParam;
225c2c66affSColin Finck SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
226c2c66affSColin Finck
227c2c66affSColin Finck /* extract the Realm from the proxy response and show it */
228c2c66affSColin Finck if( WININET_GetAuthRealm( params->req->hdr.hInternet,
229c239cdd4SAmine Khaldi szRealm, ARRAY_SIZE( szRealm ), TRUE ) )
230c2c66affSColin Finck {
231c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_REALM );
232c2c66affSColin Finck SetWindowTextW( hitem, szRealm );
233c2c66affSColin Finck }
234c2c66affSColin Finck
235c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_PROXY );
236c2c66affSColin Finck SetWindowTextW( hitem, params->req->session->appInfo->proxy );
237c2c66affSColin Finck
238c239cdd4SAmine Khaldi WININET_GetSetPassword( hdlg, params->req->session->appInfo->proxy, szRealm, FALSE );
239c2c66affSColin Finck
240c2c66affSColin Finck return TRUE;
241c2c66affSColin Finck }
242c2c66affSColin Finck
243c2c66affSColin Finck params = (struct WININET_ErrorDlgParams*)
244c2c66affSColin Finck GetWindowLongPtrW( hdlg, GWLP_USERDATA );
245c2c66affSColin Finck
246c2c66affSColin Finck switch( uMsg )
247c2c66affSColin Finck {
248c2c66affSColin Finck case WM_COMMAND:
249c2c66affSColin Finck if( wParam == IDOK )
250c2c66affSColin Finck {
251c2c66affSColin Finck WCHAR username[0x20], password[0x20];
252c2c66affSColin Finck
253c2c66affSColin Finck username[0] = 0;
254c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_USERNAME );
255c2c66affSColin Finck if( hitem )
256c239cdd4SAmine Khaldi GetWindowTextW( hitem, username, ARRAY_SIZE( username ));
257c2c66affSColin Finck
258c2c66affSColin Finck password[0] = 0;
259c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_PASSWORD );
260c2c66affSColin Finck if( hitem )
261c239cdd4SAmine Khaldi GetWindowTextW( hitem, password, ARRAY_SIZE( password ));
262c2c66affSColin Finck
263c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_SAVEPASSWORD );
264c2c66affSColin Finck if( hitem &&
265c2c66affSColin Finck SendMessageW( hitem, BM_GETSTATE, 0, 0 ) &&
266c2c66affSColin Finck WININET_GetAuthRealm( params->req->hdr.hInternet,
267c239cdd4SAmine Khaldi szRealm, ARRAY_SIZE( szRealm ), TRUE) )
268c2c66affSColin Finck WININET_GetSetPassword( hdlg, params->req->session->appInfo->proxy, szRealm, TRUE );
269c2c66affSColin Finck WININET_SetAuthorization( params->req, username, password, TRUE );
270c2c66affSColin Finck
271c2c66affSColin Finck EndDialog( hdlg, ERROR_INTERNET_FORCE_RETRY );
272c2c66affSColin Finck return TRUE;
273c2c66affSColin Finck }
274c2c66affSColin Finck if( wParam == IDCANCEL )
275c2c66affSColin Finck {
276c2c66affSColin Finck EndDialog( hdlg, 0 );
277c2c66affSColin Finck return TRUE;
278c2c66affSColin Finck }
279c2c66affSColin Finck break;
280c2c66affSColin Finck }
281c2c66affSColin Finck return FALSE;
282c2c66affSColin Finck }
283c2c66affSColin Finck
284c2c66affSColin Finck /***********************************************************************
285c2c66affSColin Finck * WININET_PasswordDialog
286c2c66affSColin Finck */
WININET_PasswordDialog(HWND hdlg,UINT uMsg,WPARAM wParam,LPARAM lParam)287c2c66affSColin Finck static INT_PTR WINAPI WININET_PasswordDialog(
288c2c66affSColin Finck HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
289c2c66affSColin Finck {
290c2c66affSColin Finck HWND hitem;
291c2c66affSColin Finck struct WININET_ErrorDlgParams *params;
292c239cdd4SAmine Khaldi WCHAR szRealm[0x80];
293c2c66affSColin Finck
294c2c66affSColin Finck if( uMsg == WM_INITDIALOG )
295c2c66affSColin Finck {
296c2c66affSColin Finck TRACE("WM_INITDIALOG (%08lx)\n", lParam);
297c2c66affSColin Finck
298c2c66affSColin Finck /* save the parameter list */
299c2c66affSColin Finck params = (struct WININET_ErrorDlgParams*) lParam;
300c2c66affSColin Finck SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
301c2c66affSColin Finck
302c2c66affSColin Finck /* extract the Realm from the response and show it */
303c2c66affSColin Finck if( WININET_GetAuthRealm( params->req->hdr.hInternet,
304c239cdd4SAmine Khaldi szRealm, ARRAY_SIZE( szRealm ), FALSE ) )
305c2c66affSColin Finck {
306c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_REALM );
307c2c66affSColin Finck SetWindowTextW( hitem, szRealm );
308c2c66affSColin Finck }
309c2c66affSColin Finck
310c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_SERVER );
311c2c66affSColin Finck SetWindowTextW( hitem, params->req->session->hostName );
312c2c66affSColin Finck
313c239cdd4SAmine Khaldi WININET_GetSetPassword( hdlg, params->req->session->hostName, szRealm, FALSE );
314c2c66affSColin Finck
315c2c66affSColin Finck return TRUE;
316c2c66affSColin Finck }
317c2c66affSColin Finck
318c2c66affSColin Finck params = (struct WININET_ErrorDlgParams*)
319c2c66affSColin Finck GetWindowLongPtrW( hdlg, GWLP_USERDATA );
320c2c66affSColin Finck
321c2c66affSColin Finck switch( uMsg )
322c2c66affSColin Finck {
323c2c66affSColin Finck case WM_COMMAND:
324c2c66affSColin Finck if( wParam == IDOK )
325c2c66affSColin Finck {
326c2c66affSColin Finck WCHAR username[0x20], password[0x20];
327c2c66affSColin Finck
328c2c66affSColin Finck username[0] = 0;
329c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_USERNAME );
330c2c66affSColin Finck if( hitem )
331c239cdd4SAmine Khaldi GetWindowTextW( hitem, username, ARRAY_SIZE( username ));
332c2c66affSColin Finck
333c2c66affSColin Finck password[0] = 0;
334c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_PASSWORD );
335c2c66affSColin Finck if( hitem )
336c239cdd4SAmine Khaldi GetWindowTextW( hitem, password, ARRAY_SIZE( password ));
337c2c66affSColin Finck
338c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_SAVEPASSWORD );
339c2c66affSColin Finck if( hitem &&
340c2c66affSColin Finck SendMessageW( hitem, BM_GETSTATE, 0, 0 ) &&
341c2c66affSColin Finck WININET_GetAuthRealm( params->req->hdr.hInternet,
342c239cdd4SAmine Khaldi szRealm, ARRAY_SIZE( szRealm ), FALSE ))
343c2c66affSColin Finck {
344c2c66affSColin Finck WININET_GetSetPassword( hdlg, params->req->session->hostName, szRealm, TRUE );
345c2c66affSColin Finck }
346c2c66affSColin Finck WININET_SetAuthorization( params->req, username, password, FALSE );
347c2c66affSColin Finck
348c2c66affSColin Finck EndDialog( hdlg, ERROR_INTERNET_FORCE_RETRY );
349c2c66affSColin Finck return TRUE;
350c2c66affSColin Finck }
351c2c66affSColin Finck if( wParam == IDCANCEL )
352c2c66affSColin Finck {
353c2c66affSColin Finck EndDialog( hdlg, 0 );
354c2c66affSColin Finck return TRUE;
355c2c66affSColin Finck }
356c2c66affSColin Finck break;
357c2c66affSColin Finck }
358c2c66affSColin Finck return FALSE;
359c2c66affSColin Finck }
360c2c66affSColin Finck
361c2c66affSColin Finck /***********************************************************************
362c2c66affSColin Finck * WININET_InvalidCertificateDialog
363c2c66affSColin Finck */
WININET_InvalidCertificateDialog(HWND hdlg,UINT uMsg,WPARAM wParam,LPARAM lParam)364c2c66affSColin Finck static INT_PTR WINAPI WININET_InvalidCertificateDialog(
365c2c66affSColin Finck HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
366c2c66affSColin Finck {
367c2c66affSColin Finck struct WININET_ErrorDlgParams *params;
368c2c66affSColin Finck HWND hitem;
369c2c66affSColin Finck WCHAR buf[1024];
370c2c66affSColin Finck
371c2c66affSColin Finck if( uMsg == WM_INITDIALOG )
372c2c66affSColin Finck {
373c2c66affSColin Finck TRACE("WM_INITDIALOG (%08lx)\n", lParam);
374c2c66affSColin Finck
375c2c66affSColin Finck /* save the parameter list */
376c2c66affSColin Finck params = (struct WININET_ErrorDlgParams*) lParam;
377c2c66affSColin Finck SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
378c2c66affSColin Finck
379c2c66affSColin Finck switch( params->dwError )
380c2c66affSColin Finck {
381c2c66affSColin Finck case ERROR_INTERNET_INVALID_CA:
382c2c66affSColin Finck LoadStringW( WININET_hModule, IDS_CERT_CA_INVALID, buf, 1024 );
383c2c66affSColin Finck break;
384c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
385c2c66affSColin Finck LoadStringW( WININET_hModule, IDS_CERT_DATE_INVALID, buf, 1024 );
386c2c66affSColin Finck break;
387c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_CN_INVALID:
388c2c66affSColin Finck LoadStringW( WININET_hModule, IDS_CERT_CN_INVALID, buf, 1024 );
389c2c66affSColin Finck break;
390c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_ERRORS:
391c2c66affSColin Finck /* FIXME: We should fetch information about the
392c2c66affSColin Finck * certificate here and show all the relevant errors.
393c2c66affSColin Finck */
394c2c66affSColin Finck LoadStringW( WININET_hModule, IDS_CERT_ERRORS, buf, 1024 );
395c2c66affSColin Finck break;
396c2c66affSColin Finck default:
397c2c66affSColin Finck FIXME( "No message for error %d\n", params->dwError );
398c2c66affSColin Finck buf[0] = '\0';
399c2c66affSColin Finck }
400c2c66affSColin Finck
401c2c66affSColin Finck hitem = GetDlgItem( hdlg, IDC_CERT_ERROR );
402c2c66affSColin Finck SetWindowTextW( hitem, buf );
403c2c66affSColin Finck
404c2c66affSColin Finck return TRUE;
405c2c66affSColin Finck }
406c2c66affSColin Finck
407c2c66affSColin Finck params = (struct WININET_ErrorDlgParams*)
408c2c66affSColin Finck GetWindowLongPtrW( hdlg, GWLP_USERDATA );
409c2c66affSColin Finck
410c2c66affSColin Finck switch( uMsg )
411c2c66affSColin Finck {
412c2c66affSColin Finck case WM_COMMAND:
413c2c66affSColin Finck if( wParam == IDOK )
414c2c66affSColin Finck {
415c2c66affSColin Finck if( params->dwFlags & FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS )
416c2c66affSColin Finck {
417c2c66affSColin Finck http_request_t *req = params->req;
418c2c66affSColin Finck DWORD flags, size = sizeof(flags);
419c2c66affSColin Finck
420c2c66affSColin Finck InternetQueryOptionW( req->hdr.hInternet, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size );
421c2c66affSColin Finck switch( params->dwError )
422c2c66affSColin Finck {
423c2c66affSColin Finck case ERROR_INTERNET_INVALID_CA:
424c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
425c2c66affSColin Finck break;
426c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
427c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
428c2c66affSColin Finck break;
429c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_CN_INVALID:
430c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
431c2c66affSColin Finck break;
432c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_REV_FAILED:
433c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_REVOCATION;
434c2c66affSColin Finck break;
435c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_ERRORS:
436c2c66affSColin Finck if(flags & _SECURITY_FLAG_CERT_REV_FAILED)
437c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_REVOCATION;
438c2c66affSColin Finck if(flags & _SECURITY_FLAG_CERT_INVALID_CA)
439c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
440c2c66affSColin Finck if(flags & _SECURITY_FLAG_CERT_INVALID_CN)
441c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
442c2c66affSColin Finck if(flags & _SECURITY_FLAG_CERT_INVALID_DATE)
443c2c66affSColin Finck flags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
444c2c66affSColin Finck break;
445c2c66affSColin Finck }
446c2c66affSColin Finck /* FIXME: Use helper function */
447c2c66affSColin Finck flags |= SECURITY_FLAG_SECURE;
448c2c66affSColin Finck req->security_flags |= flags;
449c2c66affSColin Finck if(is_valid_netconn(req->netconn))
450c2c66affSColin Finck req->netconn->security_flags |= flags;
451c2c66affSColin Finck }
452c2c66affSColin Finck
453c2c66affSColin Finck EndDialog( hdlg, ERROR_SUCCESS );
454c2c66affSColin Finck return TRUE;
455c2c66affSColin Finck }
456c2c66affSColin Finck if( wParam == IDCANCEL )
457c2c66affSColin Finck {
458c2c66affSColin Finck TRACE("Pressed cancel.\n");
459c2c66affSColin Finck
460c2c66affSColin Finck EndDialog( hdlg, ERROR_CANCELLED );
461c2c66affSColin Finck return TRUE;
462c2c66affSColin Finck }
463c2c66affSColin Finck break;
464c2c66affSColin Finck }
465c2c66affSColin Finck
466c2c66affSColin Finck return FALSE;
467c2c66affSColin Finck }
468c2c66affSColin Finck
469c2c66affSColin Finck /***********************************************************************
470c2c66affSColin Finck * InternetErrorDlg
471c2c66affSColin Finck */
InternetErrorDlg(HWND hWnd,HINTERNET hRequest,DWORD dwError,DWORD dwFlags,LPVOID * lppvData)472c2c66affSColin Finck DWORD WINAPI InternetErrorDlg(HWND hWnd, HINTERNET hRequest,
473c2c66affSColin Finck DWORD dwError, DWORD dwFlags, LPVOID* lppvData)
474c2c66affSColin Finck {
475c2c66affSColin Finck struct WININET_ErrorDlgParams params;
476c2c66affSColin Finck http_request_t *req = NULL;
477c2c66affSColin Finck DWORD res = ERROR_SUCCESS;
478c2c66affSColin Finck
479c2c66affSColin Finck TRACE("%p %p %d %08x %p\n", hWnd, hRequest, dwError, dwFlags, lppvData);
480c2c66affSColin Finck
481c2c66affSColin Finck if( !hWnd && !(dwFlags & FLAGS_ERROR_UI_FLAGS_NO_UI) )
482c2c66affSColin Finck return ERROR_INVALID_HANDLE;
483c2c66affSColin Finck
484c2c66affSColin Finck if(hRequest) {
485c2c66affSColin Finck req = (http_request_t*)get_handle_object(hRequest);
486c2c66affSColin Finck if(!req)
487c2c66affSColin Finck return ERROR_INVALID_HANDLE;
488c2c66affSColin Finck if(req->hdr.htype != WH_HHTTPREQ)
489c2c66affSColin Finck return ERROR_SUCCESS; /* Yes, that was tested */
490c2c66affSColin Finck }
491c2c66affSColin Finck
492c2c66affSColin Finck params.req = req;
493c2c66affSColin Finck params.hWnd = hWnd;
494c2c66affSColin Finck params.dwError = dwError;
495c2c66affSColin Finck params.dwFlags = dwFlags;
496c2c66affSColin Finck params.lppvData = lppvData;
497c2c66affSColin Finck
498c2c66affSColin Finck switch( dwError )
499c2c66affSColin Finck {
500c2c66affSColin Finck case ERROR_SUCCESS:
501c2c66affSColin Finck case ERROR_INTERNET_INCORRECT_PASSWORD: {
502c2c66affSColin Finck if( !dwError && !(dwFlags & FLAGS_ERROR_UI_FILTER_FOR_ERRORS ) )
503c2c66affSColin Finck break;
504c2c66affSColin Finck if(!req)
505c2c66affSColin Finck return ERROR_INVALID_HANDLE;
506c2c66affSColin Finck
507c2c66affSColin Finck switch(req->status_code) {
508c2c66affSColin Finck case HTTP_STATUS_PROXY_AUTH_REQ:
509c2c66affSColin Finck res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_PROXYDLG ),
510c2c66affSColin Finck hWnd, WININET_ProxyPasswordDialog, (LPARAM) ¶ms );
511c2c66affSColin Finck break;
512c2c66affSColin Finck case HTTP_STATUS_DENIED:
513c2c66affSColin Finck res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_AUTHDLG ),
514c2c66affSColin Finck hWnd, WININET_PasswordDialog, (LPARAM) ¶ms );
515c2c66affSColin Finck break;
516c2c66affSColin Finck default:
517c2c66affSColin Finck WARN("unhandled status %u\n", req->status_code);
518c2c66affSColin Finck }
519c2c66affSColin Finck break;
520c2c66affSColin Finck }
521c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_ERRORS:
522c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_CN_INVALID:
523c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
524c2c66affSColin Finck case ERROR_INTERNET_INVALID_CA:
525c2c66affSColin Finck case ERROR_INTERNET_SEC_CERT_REV_FAILED:
526c2c66affSColin Finck if( dwFlags & FLAGS_ERROR_UI_FLAGS_NO_UI ) {
527c2c66affSColin Finck res = ERROR_CANCELLED;
528c2c66affSColin Finck break;
529c2c66affSColin Finck }
530c2c66affSColin Finck if(!req)
531c2c66affSColin Finck return ERROR_INVALID_HANDLE;
532c2c66affSColin Finck
533c2c66affSColin Finck
534c2c66affSColin Finck if( dwFlags & ~FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS )
535c2c66affSColin Finck FIXME("%08x contains unsupported flags.\n", dwFlags);
536c2c66affSColin Finck
537c2c66affSColin Finck res = DialogBoxParamW( WININET_hModule, MAKEINTRESOURCEW( IDD_INVCERTDLG ),
538c2c66affSColin Finck hWnd, WININET_InvalidCertificateDialog, (LPARAM) ¶ms );
539c2c66affSColin Finck break;
540c2c66affSColin Finck case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
541c2c66affSColin Finck case ERROR_INTERNET_POST_IS_NON_SECURE:
542c2c66affSColin Finck FIXME("Need to display dialog for error %d\n", dwError);
543c2c66affSColin Finck res = ERROR_SUCCESS;
544c2c66affSColin Finck break;
545c2c66affSColin Finck default:
546c2c66affSColin Finck res = ERROR_NOT_SUPPORTED;
547c2c66affSColin Finck }
548c2c66affSColin Finck
549c2c66affSColin Finck if(req)
550c2c66affSColin Finck WININET_Release(&req->hdr);
551c2c66affSColin Finck return res;
552c2c66affSColin Finck }
553c2c66affSColin Finck
554c2c66affSColin Finck /***********************************************************************
555c2c66affSColin Finck * InternetShowSecurityInfoByURLA (@)
556c2c66affSColin Finck */
InternetShowSecurityInfoByURLA(LPCSTR url,HWND window)557c2c66affSColin Finck BOOL WINAPI InternetShowSecurityInfoByURLA(LPCSTR url, HWND window)
558c2c66affSColin Finck {
559c2c66affSColin Finck FIXME("stub: %s %p\n", url, window);
560c2c66affSColin Finck return FALSE;
561c2c66affSColin Finck }
562c2c66affSColin Finck
563c2c66affSColin Finck /***********************************************************************
564c2c66affSColin Finck * InternetShowSecurityInfoByURLW (@)
565c2c66affSColin Finck */
InternetShowSecurityInfoByURLW(LPCWSTR url,HWND window)566c2c66affSColin Finck BOOL WINAPI InternetShowSecurityInfoByURLW(LPCWSTR url, HWND window)
567c2c66affSColin Finck {
568c2c66affSColin Finck FIXME("stub: %s %p\n", debugstr_w(url), window);
569c2c66affSColin Finck return FALSE;
570c2c66affSColin Finck }
571c2c66affSColin Finck
572c2c66affSColin Finck /***********************************************************************
573bc01cef0SAmine Khaldi * ParseX509EncodedCertificateForListBoxEntry (@)
574bc01cef0SAmine Khaldi */
ParseX509EncodedCertificateForListBoxEntry(LPBYTE cert,DWORD len,LPSTR szlistbox,LPDWORD listbox)575bc01cef0SAmine Khaldi DWORD WINAPI ParseX509EncodedCertificateForListBoxEntry(LPBYTE cert, DWORD len, LPSTR szlistbox, LPDWORD listbox)
576bc01cef0SAmine Khaldi {
577bc01cef0SAmine Khaldi FIXME("stub: %p %d %s %p\n", cert, len, debugstr_a(szlistbox), listbox);
578bc01cef0SAmine Khaldi return ERROR_CALL_NOT_IMPLEMENTED;
579bc01cef0SAmine Khaldi }
580bc01cef0SAmine Khaldi
581bc01cef0SAmine Khaldi /***********************************************************************
582c2c66affSColin Finck * ShowX509EncodedCertificate (@)
583c2c66affSColin Finck */
ShowX509EncodedCertificate(HWND parent,LPBYTE cert,DWORD len)584c2c66affSColin Finck DWORD WINAPI ShowX509EncodedCertificate(HWND parent, LPBYTE cert, DWORD len)
585c2c66affSColin Finck {
586c2c66affSColin Finck PCCERT_CONTEXT certContext = CertCreateCertificateContext(X509_ASN_ENCODING,
587c2c66affSColin Finck cert, len);
588c2c66affSColin Finck DWORD ret;
589c2c66affSColin Finck
590c2c66affSColin Finck if (certContext)
591c2c66affSColin Finck {
592c2c66affSColin Finck CRYPTUI_VIEWCERTIFICATE_STRUCTW view;
593c2c66affSColin Finck
594c2c66affSColin Finck memset(&view, 0, sizeof(view));
595c2c66affSColin Finck view.hwndParent = parent;
596c2c66affSColin Finck view.pCertContext = certContext;
597c2c66affSColin Finck if (CryptUIDlgViewCertificateW(&view, NULL))
598c2c66affSColin Finck ret = ERROR_SUCCESS;
599c2c66affSColin Finck else
600c2c66affSColin Finck ret = GetLastError();
601c2c66affSColin Finck CertFreeCertificateContext(certContext);
602c2c66affSColin Finck }
603c2c66affSColin Finck else
604c2c66affSColin Finck ret = GetLastError();
605c2c66affSColin Finck return ret;
606c2c66affSColin Finck }
607