VirtualBox

Changeset 45398 in vbox


Ignore:
Timestamp:
Apr 8, 2013 9:32:00 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84824
Message:

Runtime/http: more error codes

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/err.h

    r45389 r45398  
    15721572/** @name HTTP status codes
    15731573 * @{ */
     1574/** HTTP initialization failed. */
     1575#define VERR_HTTP_INIT_FAILED                   (-885)
    15741576/** The server has not found anything matching the URI given. */
    1575 #define VERR_HTTP_NOT_FOUND                     (-885)
     1577#define VERR_HTTP_NOT_FOUND                     (-886)
    15761578/** The request is for something forbidden. Authorization will not help. */
    1577 #define VERR_HTTP_ACCESS_DENIED                 (-886)
     1579#define VERR_HTTP_ACCESS_DENIED                 (-887)
    15781580/** 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)
    15821590/** @} */
    15831591
  • trunk/include/iprt/http.h

    r45339 r45398  
    6969 * @param    hHttp         HTTP interface handle.
    7070 * @param    pcszUrl       URL.
    71  * @param    ppszResponse  HTTP response.
     71 * @param    ppszResponse  HTTP response. It is guaranteed that this string is
     72 *                         '\0'-terminated.
    7273 */
    7374RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse);
  • trunk/src/VBox/Runtime/common/misc/http.cpp

    r45381 r45398  
    3535#include <iprt/string.h>
    3636#include <iprt/file.h>
     37#include <iprt/stream.h>
    3738
    3839#include <curl/curl.h>
     
    9091    CURLcode rcCurl = curl_global_init(CURL_GLOBAL_ALL);
    9192    if (CURL_FAILED(rcCurl))
    92         return VERR_INTERNAL_ERROR;
     93        return VERR_HTTP_INIT_FAILED;
    9394
    9495    CURL *pCurl = curl_easy_init();
    9596    if (!pCurl)
    96         return VERR_INTERNAL_ERROR;
     97        return VERR_HTTP_INIT_FAILED;
    9798
    9899    PRTHTTPINTERNAL pHttpInt = (PRTHTTPINTERNAL)RTMemAllocZ(sizeof(RTHTTPINTERNAL));
     
    237238                    }
    238239                    else
    239                         rc = VERR_INTERNAL_ERROR;
     240                        rc = VERR_HTTP_CACERT_WRONG_FORMAT;
    240241                }
    241242                else
     
    243244            }
    244245            else
    245                 rc = VERR_INTERNAL_ERROR;
     246                rc = VERR_HTTP_CACERT_WRONG_FORMAT;
    246247            X509_free(crt);
    247248        }
    248249        else
    249             rc = VERR_INTERNAL_ERROR;
     250            rc = VERR_HTTP_CACERT_WRONG_FORMAT;
    250251        BIO_free(cert);
    251252    }
     
    334335    else
    335336    {
     337        RTPrintf("rcCurl = %d\n", rcCurl);
    336338        switch (rcCurl)
    337339        {
     
    343345                rc = VERR_HTTP_COULDNT_CONNECT;
    344346                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;
    345359            default:
    346360                break;
  • trunk/src/VBox/Runtime/testcase/tstHttp.cpp

    r45381 r45398  
    6666        uint8_t *abSha512;
    6767        size_t  cbSha512;
     68        size_t cbBuf = strlen(pszBuf);
    6869        const uint8_t abSha1PCA3G5[] =
    6970        {
     
    8283            0xd2, 0x6b, 0xa8, 0x9a, 0xf0, 0xb3, 0x6a, 0x01
    8384        };
    84         rc = RTHttpCertDigest(hHttp, pszBuf, strlen(pszBuf),
     85        rc = RTHttpCertDigest(hHttp, pszBuf, cbBuf,
    8586                              &abSha1, &cbSha1, &abSha512, &cbSha512);
    8687        if (RT_SUCCESS(rc))
     
    115116            RTMemFree(abSha512);
    116117            if (RT_SUCCESS(rc))
    117                 rc = RTStrmWrite(CAFile, pszBuf, strlen(pszBuf));
     118                rc = RTStrmWrite(CAFile, pszBuf, cbBuf);
    118119            if (RT_SUCCESS(rc))
    119120                rc = RTStrmWrite(CAFile, RTFILE_LINEFEED, strlen(RTFILE_LINEFEED));
     
    137138        uint8_t *abSha512;
    138139        size_t  cbSha512;
     140        size_t  cbBuf = strlen(pszBuf);
    139141        const uint8_t abSha1PCA3[] =
    140142        {
     
    153155            0x0a, 0x67, 0x83, 0x87, 0xc5, 0x45, 0xc4, 0x99
    154156        };
    155         rc = RTHttpCertDigest(hHttp, pszBuf, strlen(pszBuf),
     157        rc = RTHttpCertDigest(hHttp, pszBuf, cbBuf,
    156158                              &abSha1, &cbSha1, &abSha512, &cbSha512);
    157159        if (RT_SUCCESS(rc))
     
    186188            RTMemFree(abSha512);
    187189            if (RT_SUCCESS(rc))
    188                 rc = RTStrmWrite(CAFile, pszBuf, strlen(pszBuf));
     190                rc = RTStrmWrite(CAFile, pszBuf, cbBuf);
    189191            if (RT_SUCCESS(rc))
    190192                rc = RTStrmWrite(CAFile, RTFILE_LINEFEED, strlen(RTFILE_LINEFEED));
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette