|
47 | 47 | #include "misc.h"
|
48 | 48 |
|
49 | 49 | #ifdef USE_CERT_PINNING
|
50 |
| -#define CERT_ISSUER_INFO "BE\r\nGlobalSign nv-sa\r\nGlobalSign Domain Validation CA - SHA256 - G2" |
51 |
| -#define CERT_SUBJECT_INFO "Domain Control Validated\r\n*.reactos.org" |
| 50 | +#define CERT_ISSUER_INFO "US\r\nLet's Encrypt\r\nLet's Encrypt Authority X3" |
| 51 | +#define CERT_SUBJECT_INFO "svn.reactos.org" |
52 | 52 | #endif
|
53 | 53 |
|
54 | 54 | enum DownloadStatus
|
@@ -331,55 +331,42 @@ HRESULT WINAPI CDownloadDialog_Constructor(HWND Dlg, BOOL *pbCancelled, REFIID r
|
331 | 331 | }
|
332 | 332 |
|
333 | 333 | #ifdef USE_CERT_PINNING
|
334 |
| -static BOOL CertIsValid(HINTERNET hInternet, LPWSTR lpszHostName) |
| 334 | +static BOOL CertIsValid(HINTERNET hFile, LPWSTR lpszHostName) |
335 | 335 | {
|
336 |
| - HINTERNET hConnect; |
337 |
| - HINTERNET hRequest; |
338 | 336 | DWORD certInfoLength;
|
339 |
| - BOOL Ret = FALSE; |
340 |
| - INTERNET_CERTIFICATE_INFOW certInfo; |
| 337 | + INTERNET_CERTIFICATE_INFOA certInfo; |
| 338 | + int ValidFlags = 0; |
| 339 | + |
| 340 | + /* Despite what the header indicates, the implementation of INTERNET_CERTIFICATE_INFO is not Unicode-aware. */ |
| 341 | + certInfoLength = sizeof(certInfo); |
| 342 | + if (!InternetQueryOptionA(hFile, |
| 343 | + INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, |
| 344 | + &certInfo, |
| 345 | + &certInfoLength)) |
| 346 | + { |
| 347 | + return FALSE; |
| 348 | + } |
341 | 349 |
|
342 |
| - hConnect = InternetConnectW(hInternet, lpszHostName, INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_SECURE, 0); |
343 |
| - if (hConnect) |
| 350 | + if (certInfo.lpszSubjectInfo) |
344 | 351 | {
|
345 |
| - hRequest = HttpOpenRequestW(hConnect, L"HEAD", NULL, NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0); |
346 |
| - if (hRequest != NULL) |
347 |
| - { |
348 |
| - Ret = HttpSendRequestW(hRequest, L"", 0, NULL, 0); |
349 |
| - if (Ret) |
350 |
| - { |
351 |
| - certInfoLength = sizeof(certInfo); |
352 |
| - Ret = InternetQueryOptionW(hRequest, |
353 |
| - INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT, |
354 |
| - &certInfo, |
355 |
| - &certInfoLength); |
356 |
| - if (Ret) |
357 |
| - { |
358 |
| - if (certInfo.lpszEncryptionAlgName) |
359 |
| - LocalFree(certInfo.lpszEncryptionAlgName); |
360 |
| - if (certInfo.lpszIssuerInfo) |
361 |
| - { |
362 |
| - if (strcmp((LPSTR) certInfo.lpszIssuerInfo, CERT_ISSUER_INFO) != 0) |
363 |
| - Ret = FALSE; |
364 |
| - LocalFree(certInfo.lpszIssuerInfo); |
365 |
| - } |
366 |
| - if (certInfo.lpszProtocolName) |
367 |
| - LocalFree(certInfo.lpszProtocolName); |
368 |
| - if (certInfo.lpszSignatureAlgName) |
369 |
| - LocalFree(certInfo.lpszSignatureAlgName); |
370 |
| - if (certInfo.lpszSubjectInfo) |
371 |
| - { |
372 |
| - if (strcmp((LPSTR) certInfo.lpszSubjectInfo, CERT_SUBJECT_INFO) != 0) |
373 |
| - Ret = FALSE; |
374 |
| - LocalFree(certInfo.lpszSubjectInfo); |
375 |
| - } |
376 |
| - } |
377 |
| - } |
378 |
| - InternetCloseHandle(hRequest); |
379 |
| - } |
380 |
| - InternetCloseHandle(hConnect); |
| 352 | + if (strcmp(certInfo.lpszSubjectInfo, CERT_SUBJECT_INFO) == 0) |
| 353 | + ValidFlags |= 1; |
| 354 | + LocalFree(certInfo.lpszSubjectInfo); |
| 355 | + } |
| 356 | + if (certInfo.lpszIssuerInfo) |
| 357 | + { |
| 358 | + if (strcmp(certInfo.lpszIssuerInfo, CERT_ISSUER_INFO) == 0) |
| 359 | + ValidFlags |= 2; |
| 360 | + LocalFree(certInfo.lpszIssuerInfo); |
381 | 361 | }
|
382 |
| - return Ret; |
| 362 | + if (certInfo.lpszProtocolName) |
| 363 | + LocalFree(certInfo.lpszProtocolName); |
| 364 | + if (certInfo.lpszSignatureAlgName) |
| 365 | + LocalFree(certInfo.lpszSignatureAlgName); |
| 366 | + if (certInfo.lpszEncryptionAlgName) |
| 367 | + LocalFree(certInfo.lpszEncryptionAlgName); |
| 368 | + |
| 369 | + return ValidFlags == 3; |
383 | 370 | }
|
384 | 371 | #endif
|
385 | 372 |
|
@@ -768,7 +755,7 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
|
768 | 755 | // are we using HTTPS to download the RAPPS update package? check if the certificate is original
|
769 | 756 | if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
|
770 | 757 | (wcscmp(InfoArray[iAppId].szUrl, APPLICATION_DATABASE_URL) == 0) &&
|
771 |
| - (!CertIsValid(hOpen, urlComponents.lpszHostName))) |
| 758 | + (!CertIsValid(hFile, urlComponents.lpszHostName))) |
772 | 759 | {
|
773 | 760 | MessageBox_LoadString(hMainWnd, IDS_CERT_DOES_NOT_MATCH);
|
774 | 761 | goto end;
|
|
0 commit comments