Changeset 45398 in vbox
- Timestamp:
- Apr 8, 2013 9:32:00 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84824
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/err.h
r45389 r45398 1572 1572 /** @name HTTP status codes 1573 1573 * @{ */ 1574 /** HTTP initialization failed. */ 1575 #define VERR_HTTP_INIT_FAILED (-885) 1574 1576 /** The server has not found anything matching the URI given. */ 1575 #define VERR_HTTP_NOT_FOUND (-88 5)1577 #define VERR_HTTP_NOT_FOUND (-886) 1576 1578 /** The request is for something forbidden. Authorization will not help. */ 1577 #define VERR_HTTP_ACCESS_DENIED (-88 6)1579 #define VERR_HTTP_ACCESS_DENIED (-887) 1578 1580 /** The server did not understand the request due to bad syntax. */ 1579 #define VERR_HTTP_BAD_REQUEST (-887) 1580 /** Couldn't connect to the server (proxy?) */ 1581 #define VERR_HTTP_COULDNT_CONNECT (-888) 1581 #define VERR_HTTP_BAD_REQUEST (-888) 1582 /** Couldn't connect to the server (proxy?). */ 1583 #define VERR_HTTP_COULDNT_CONNECT (-889) 1584 /** SSL connection error. */ 1585 #define VERR_HTTP_SSL_CONNECT_ERROR (-890) 1586 /** CAcert is missing or has the wrong format. */ 1587 #define VERR_HTTP_CACERT_WRONG_FORMAT (-891) 1588 /** Certificate cannot be authenticated with the given CA certificates. */ 1589 #define VERR_HTTP_CACERT_CANNOT_AUTHENTICATE (-892) 1582 1590 /** @} */ 1583 1591 -
trunk/include/iprt/http.h
r45339 r45398 69 69 * @param hHttp HTTP interface handle. 70 70 * @param pcszUrl URL. 71 * @param ppszResponse HTTP response. 71 * @param ppszResponse HTTP response. It is guaranteed that this string is 72 * '\0'-terminated. 72 73 */ 73 74 RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse); -
trunk/src/VBox/Runtime/common/misc/http.cpp
r45381 r45398 35 35 #include <iprt/string.h> 36 36 #include <iprt/file.h> 37 #include <iprt/stream.h> 37 38 38 39 #include <curl/curl.h> … … 90 91 CURLcode rcCurl = curl_global_init(CURL_GLOBAL_ALL); 91 92 if (CURL_FAILED(rcCurl)) 92 return VERR_ INTERNAL_ERROR;93 return VERR_HTTP_INIT_FAILED; 93 94 94 95 CURL *pCurl = curl_easy_init(); 95 96 if (!pCurl) 96 return VERR_ INTERNAL_ERROR;97 return VERR_HTTP_INIT_FAILED; 97 98 98 99 PRTHTTPINTERNAL pHttpInt = (PRTHTTPINTERNAL)RTMemAllocZ(sizeof(RTHTTPINTERNAL)); … … 237 238 } 238 239 else 239 rc = VERR_ INTERNAL_ERROR;240 rc = VERR_HTTP_CACERT_WRONG_FORMAT; 240 241 } 241 242 else … … 243 244 } 244 245 else 245 rc = VERR_ INTERNAL_ERROR;246 rc = VERR_HTTP_CACERT_WRONG_FORMAT; 246 247 X509_free(crt); 247 248 } 248 249 else 249 rc = VERR_ INTERNAL_ERROR;250 rc = VERR_HTTP_CACERT_WRONG_FORMAT; 250 251 BIO_free(cert); 251 252 } … … 334 335 else 335 336 { 337 RTPrintf("rcCurl = %d\n", rcCurl); 336 338 switch (rcCurl) 337 339 { … … 343 345 rc = VERR_HTTP_COULDNT_CONNECT; 344 346 break; 347 case CURLE_SSL_CONNECT_ERROR: 348 rc = VERR_HTTP_SSL_CONNECT_ERROR; 349 break; 350 case CURLE_SSL_CACERT: 351 /* The peer certificate cannot be authenticated with the CA certificates 352 * set by RTHttpSetCAFile(). We need other or additional CA certificates. */ 353 rc = VERR_HTTP_CACERT_CANNOT_AUTHENTICATE; 354 break; 355 case CURLE_SSL_CACERT_BADFILE: 356 /* CAcert file (see RTHttpSetCAFile()) has wrong format */ 357 rc = VERR_HTTP_CACERT_WRONG_FORMAT; 358 break; 345 359 default: 346 360 break; -
trunk/src/VBox/Runtime/testcase/tstHttp.cpp
r45381 r45398 66 66 uint8_t *abSha512; 67 67 size_t cbSha512; 68 size_t cbBuf = strlen(pszBuf); 68 69 const uint8_t abSha1PCA3G5[] = 69 70 { … … 82 83 0xd2, 0x6b, 0xa8, 0x9a, 0xf0, 0xb3, 0x6a, 0x01 83 84 }; 84 rc = RTHttpCertDigest(hHttp, pszBuf, strlen(pszBuf),85 rc = RTHttpCertDigest(hHttp, pszBuf, cbBuf, 85 86 &abSha1, &cbSha1, &abSha512, &cbSha512); 86 87 if (RT_SUCCESS(rc)) … … 115 116 RTMemFree(abSha512); 116 117 if (RT_SUCCESS(rc)) 117 rc = RTStrmWrite(CAFile, pszBuf, strlen(pszBuf));118 rc = RTStrmWrite(CAFile, pszBuf, cbBuf); 118 119 if (RT_SUCCESS(rc)) 119 120 rc = RTStrmWrite(CAFile, RTFILE_LINEFEED, strlen(RTFILE_LINEFEED)); … … 137 138 uint8_t *abSha512; 138 139 size_t cbSha512; 140 size_t cbBuf = strlen(pszBuf); 139 141 const uint8_t abSha1PCA3[] = 140 142 { … … 153 155 0x0a, 0x67, 0x83, 0x87, 0xc5, 0x45, 0xc4, 0x99 154 156 }; 155 rc = RTHttpCertDigest(hHttp, pszBuf, strlen(pszBuf),157 rc = RTHttpCertDigest(hHttp, pszBuf, cbBuf, 156 158 &abSha1, &cbSha1, &abSha512, &cbSha512); 157 159 if (RT_SUCCESS(rc)) … … 186 188 RTMemFree(abSha512); 187 189 if (RT_SUCCESS(rc)) 188 rc = RTStrmWrite(CAFile, pszBuf, strlen(pszBuf));190 rc = RTStrmWrite(CAFile, pszBuf, cbBuf); 189 191 if (RT_SUCCESS(rc)) 190 192 rc = RTStrmWrite(CAFile, RTFILE_LINEFEED, strlen(RTFILE_LINEFEED));
Note:
See TracChangeset
for help on using the changeset viewer.