0

我正在使用 libcurl 从 Windows azure 下载 blob,该 blob 已公开并能够通过 http 站点成功下载。但是,如果 azure blob 存储使用自签名证书和私钥设为私有,则文件下载失败并显示消息“指定的资源不存在”

代码如下

CURL *curl; 
    FILE *fp; 
    CURLcode res; 
    bool success = true;
    string CloudContainerPath = "https://MyTest.blob.core.windows.net/Mytest/";
    string path = CloudContainerPath+fileNameJsonVal.asCString();
    char *url = &path[0];  
    char *outfilename = (char *)fileNameJsonVal.asCString(); 
    char                errbuf[CURL_ERROR_SIZE];
    int length = 0;
    errbuf[0] = '\0';

static const char *pCACertFile = "D:\\LibCURL\\cacert.pem";
curl_easy_setopt(curl, CURLOPT_URL, url); 
                curl_easy_setopt(curl, CURLOPT_HEADER, 0); 
                * set the file with the certs vaildating the server */ 
                curl_easy_setopt(curl, CURLOPT_CAPATH,pCACertFile);
                curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile);


                curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
                curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 1);
                curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); 
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); 


res = curl_easy_perform(curl); 
                curl_easy_cleanup(curl); 
                fclose(

fp);

4

1 回答 1

0

Windows Azure 存储不使用基于证书的身份验证。它使用带有 HMAC 签名的共享密钥。请参阅http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx

于 2012-12-04T18:17:35.870 回答