Changeset 78066 in vbox
- Timestamp:
- Apr 9, 2019 4:02:32 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
include/iprt/http.h (modified) (2 diffs)
-
include/iprt/mangling.h (modified) (1 diff)
-
src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp (modified) (3 diffs)
-
src/VBox/Frontends/VirtualBox/src/net/tstSSLCertDownloads.cpp (modified) (2 diffs)
-
src/VBox/Runtime/generic/http-curl.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/http.h
r76585 r78066 319 319 320 320 /** 321 * Gets the follow redirect setting. 322 * 323 * @returns cMaxRedirects value, 0 means not to follow. 324 * @param hHttp The HTTP client handle. 325 */ 326 RTR3DECL(uint32_t) RTHttpGetFollowRedirects(RTHTTP hHttp); 327 328 /** 321 329 * Set custom raw headers. 322 330 * … … 468 476 */ 469 477 RTR3DECL(int) RTHttpGatherCaCertsInFile(const char *pszCaFile, uint32_t fFlags, PRTERRINFO pErrInfo); 478 479 /** 480 * Set whether to verify the peer's SSL certificate. 481 * 482 * The default is to verify it. It can however sometimes be useful or even 483 * necessary to skip this. 484 * 485 * @returns iprt status code. 486 * 487 * @param hHttp The HTTP client handle. 488 * @param fVerify Verify the certificate if @a true. 489 */ 490 RTR3DECL(int) RTHttpSetVerifyPeer(RTHTTP hHttp, bool fVerify); 491 492 /** 493 * Get the state of the peer's SSL certificate setting. 494 * 495 * @returns true if we verify the SSL certificate, false if not. 496 * @param hHttp The HTTP client handle. 497 */ 498 RTR3DECL(bool) RTHttpGetVerifyPeer(RTHTTP hHttp); 470 499 471 500 /** -
trunk/include/iprt/mangling.h
r78048 r78066 1131 1131 # define RTHeapSimpleSize RT_MANGLER(RTHeapSimpleSize) 1132 1132 # define RTHttpGetFile RT_MANGLER(RTHttpGetFile) 1133 # define RTHttpGetFollowRedirects RT_MANGLER(RTHttpGetFollowRedirects) 1133 1134 # define RTHttpSetFollowRedirects RT_MANGLER(RTHttpSetFollowRedirects) 1135 # define RTHttpGetVerifyPeer RT_MANGLER(RTHttpGetVerifyPeer) 1136 # define RTHttpSetVerifyPeer RT_MANGLER(RTHttpSetVerifyPeer) 1134 1137 # define RTHttpUseSystemProxySettings RT_MANGLER(RTHttpUseSystemProxySettings) 1135 1138 # define RTIniFileCreateFromVfsFile RT_MANGLER(RTIniFileCreateFromVfsFile) -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp
r76606 r78066 777 777 NOREF(pStaticErrInfo); 778 778 int rc; 779 780 /* 781 * Must disable SSL certification verification here as we cannot use the 782 * SSL certificates before we've downloaded them. We must also enable 783 * redirections in case the certificates moves around. 784 */ 785 bool const fSavedVerifyPeer = RTHttpGetVerifyPeer(hHttp); 786 uint32_t const cSavedMaxRedirects = RTHttpGetFollowRedirects(hHttp); 787 RTHttpSetVerifyPeer(hHttp, false); 788 RTHttpSetFollowRedirects(hHttp, 8); 779 789 780 790 /* … … 810 820 { 811 821 RTHttpFreeResponse(pvRootsZip); 822 RTHttpSetVerifyPeer(hHttp, fSavedVerifyPeer); 823 RTHttpSetFollowRedirects(hHttp, cSavedMaxRedirects); 812 824 return; 813 825 } … … 845 857 } 846 858 } 859 860 RTHttpSetVerifyPeer(hHttp, fSavedVerifyPeer); 861 RTHttpSetFollowRedirects(hHttp, cSavedMaxRedirects); 847 862 } 848 863 -
trunk/src/VBox/Frontends/VirtualBox/src/net/tstSSLCertDownloads.cpp
r76553 r78066 57 57 int rc; 58 58 59 bool const fSavedVerifyPeer = RTHttpGetVerifyPeer(TestObj.m_hHttp); 60 uint32_t const cSavedMaxRedirects = RTHttpGetFollowRedirects(TestObj.m_hHttp); 61 RTTESTI_CHECK_RC(RTHttpSetVerifyPeer(TestObj.m_hHttp, false), VINF_SUCCESS); 62 RTTESTI_CHECK_RC(RTHttpSetFollowRedirects(TestObj.m_hHttp, 8), VINF_SUCCESS); 63 RTTESTI_CHECK(RTHttpGetVerifyPeer(TestObj.m_hHttp) == false); 64 RTTESTI_CHECK(RTHttpGetFollowRedirects(TestObj.m_hHttp) == 8); 65 59 66 /* ZIP files: */ 60 67 for (uint32_t iUrl = 0; iUrl < RT_ELEMENTS(s_apszRootsZipUrls); iUrl++) … … 113 120 RTTESTI_CHECK(RTCrStoreRelease(hStore) == 0); 114 121 122 RTTESTI_CHECK_RC(RTHttpSetVerifyPeer(TestObj.m_hHttp, fSavedVerifyPeer), VINF_SUCCESS); 123 RTTESTI_CHECK_RC(RTHttpSetFollowRedirects(TestObj.m_hHttp, cSavedMaxRedirects), VINF_SUCCESS); 124 115 125 /* 116 126 * Now check the gathering of certificates on the system doesn't crash. -
trunk/src/VBox/Runtime/generic/http-curl.cpp
r76553 r78066 188 188 * Zero if not automatically following (default). */ 189 189 uint32_t cMaxRedirects; 190 /** Whether to check if Peer lies about his SSL certificate. */ 191 bool fVerifyPeer; 190 192 /** @} */ 191 193 … … 384 386 pThis->fUseSystemProxySettings = true; 385 387 pThis->cMaxRedirects = 0; /* no automatic redir following */ 388 pThis->fVerifyPeer = true; 386 389 pThis->BodyOutput.pHttp = pThis; 387 390 pThis->HeadersOutput.pHttp = pThis; … … 418 421 curl_easy_reset(pThis->pCurl); 419 422 423 /** @todo check if CURLOPT_SSL_VERIFYPEER is affected by curl_easy_reset. */ 424 420 425 if (!(fFlags & RTHTTP_RESET_F_KEEP_HEADERS)) 421 426 rtHttpFreeHeaders(pThis); … … 523 528 } 524 529 return VINF_SUCCESS; 530 } 531 532 533 RTR3DECL(uint32_t) RTHttpGetFollowRedirects(RTHTTP hHttp) 534 { 535 PRTHTTPINTERNAL pThis = hHttp; 536 RTHTTP_VALID_RETURN_RC(pThis, 0); 537 return pThis->cMaxRedirects; 525 538 } 526 539 … … 2615 2628 RT_NOREF_PV(fFlags); 2616 2629 2617 2618 2630 /* 2619 2631 * Add the user store, quitely ignoring any errors. … … 2671 2683 } 2672 2684 return rc; 2685 } 2686 2687 2688 RTR3DECL(bool) RTHttpGetVerifyPeer(RTHTTP hHttp) 2689 { 2690 PRTHTTPINTERNAL pThis = hHttp; 2691 RTHTTP_VALID_RETURN_RC(pThis, false); 2692 return pThis->fVerifyPeer; 2693 } 2694 2695 2696 RTR3DECL(int) RTHttpSetVerifyPeer(RTHTTP hHttp, bool fVerify) 2697 { 2698 PRTHTTPINTERNAL pThis = hHttp; 2699 RTHTTP_VALID_RETURN(pThis); 2700 AssertReturn(!pThis->fBusy, VERR_WRONG_ORDER); 2701 2702 if (pThis->fVerifyPeer != fVerify) 2703 { 2704 int rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_SSL_VERIFYPEER, (long)fVerify); 2705 AssertMsgReturn(rcCurl == CURLE_OK, ("CURLOPT_SSL_VERIFYPEER=%RTbool: %d (%#x)\n", fVerify, rcCurl, rcCurl), 2706 VERR_HTTP_CURL_ERROR); 2707 pThis->fVerifyPeer = fVerify; 2708 } 2709 2710 return VINF_SUCCESS; 2673 2711 } 2674 2712
Note:
See TracChangeset
for help on using the changeset viewer.

