VirtualBox

Changeset 45331 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Apr 4, 2013 9:37:00 AM (12 years ago)
Author:
vboxsync
Message:

Runtime/http: add new function to set the filename containing the trusted root certificates, plus an extension of the testcase which fetches the root certificates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/http.cpp

    r43713 r45331  
    1 
    21/* $Id$ */
    32/** @file
     
    65
    76/*
    8  * Copyright (C) 2012 Oracle Corporation
     7 * Copyright (C) 2012-2013 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3534#include <iprt/mem.h>
    3635#include <iprt/string.h>
     36#include <iprt/file.h>
    3737
    3838#include <curl/curl.h>
     
    4949    long lLastResp;
    5050    struct curl_slist *pHeaders;
     51    const char *pcszCAFile;
    5152} RTHTTPINTERNAL;
    5253typedef RTHTTPINTERNAL *PRTHTTPINTERNAL;
     
    198199}
    199200
     201RTR3DECL(int) RTHttpSetCAFile(RTHTTP hHttp, const char *pcszCAFile)
     202{
     203    PRTHTTPINTERNAL pHttpInt = hHttp;
     204    RTHTTP_VALID_RETURN(pHttpInt);
     205
     206    pHttpInt->pcszCAFile = pcszCAFile;
     207
     208    return VINF_SUCCESS;
     209}
     210
    200211RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse)
    201212{
     
    213224#endif
    214225
    215     /* XXX */
    216     rcCurl = curl_easy_setopt(pHttpInt->pCurl, CURLOPT_CAINFO, "/etc/ssl/certs/ca-certificates.crt");
    217     if (CURL_FAILED(rcCurl))
    218         return VERR_INTERNAL_ERROR;
     226    const char *pcszCAFile = "/etc/ssl/certs/ca-certificates.crt";
     227    if (pHttpInt->pcszCAFile)
     228        pcszCAFile = pHttpInt->pcszCAFile;
     229    if (RTFileExists(pcszCAFile))
     230    {
     231        rcCurl = curl_easy_setopt(pHttpInt->pCurl, CURLOPT_CAINFO, pcszCAFile);
     232        if (CURL_FAILED(rcCurl))
     233            return VERR_INTERNAL_ERROR;
     234    }
    219235
    220236    RTHTTPMEMCHUNK chunk = { NULL, 0 };
Note: See TracChangeset for help on using the changeset viewer.

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