Changeset 45343 in vbox for trunk/src/VBox
- Timestamp:
- Apr 4, 2013 5:24:03 PM (12 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/http.cpp
r45340 r45343 92 92 return VERR_INTERNAL_ERROR; 93 93 94 CURL *pCurl = curl_easy_init();94 CURL *pCurl = curl_easy_init(); 95 95 if (!pCurl) 96 96 return VERR_INTERNAL_ERROR; … … 119 119 120 120 curl_easy_cleanup(pHttpInt->pCurl); 121 121 122 122 if (pHttpInt->pHeaders) 123 123 curl_slist_free_all(pHttpInt->pHeaders); … … 188 188 } 189 189 190 struct curl_slist *pHeaders = NULL;190 struct curl_slist *pHeaders = NULL; 191 191 for (unsigned i = 0; i < cHeaders; i++) 192 192 pHeaders = curl_slist_append(pHeaders, pcszHeaders[i]); … … 204 204 uint8_t **pabSha512, size_t *pcbSha512) 205 205 { 206 int rc = VINF_SUCCESS; 207 206 208 BIO *cert = BIO_new_mem_buf(pcszCert, (int)cbCert); 207 if (!cert) 208 return VERR_INTERNAL_ERROR; 209 210 X509 *crt = NULL; 211 if (!PEM_read_bio_X509(cert, &crt, NULL, NULL)) 212 return VERR_INTERNAL_ERROR; 213 214 unsigned cb; 215 unsigned char md[EVP_MAX_MD_SIZE]; 216 217 const EVP_MD *digest = EVP_sha1(); 218 int rc = X509_digest(crt, digest, md, &cb); 219 if (rc <= 0) 220 return VERR_INTERNAL_ERROR; 221 *pabSha1 = (uint8_t*)RTMemAlloc(cb); 222 if (!*pabSha1) 223 return VERR_NO_MEMORY; 224 memcpy(*pabSha1, md, cb); 225 *pcbSha1 = cb; 226 227 digest = EVP_sha512(); 228 rc = X509_digest(crt, digest, md, &cb); 229 if (rc <= 0) 230 { 209 if (cert) 210 { 211 X509 *crt = NULL; 212 if (PEM_read_bio_X509(cert, &crt, NULL, NULL)) 213 { 214 unsigned cb; 215 unsigned char md[EVP_MAX_MD_SIZE]; 216 217 int rc1 = X509_digest(crt, EVP_sha1(), md, &cb); 218 if (rc1 > 0) 219 { 220 *pabSha1 = (uint8_t*)RTMemAlloc(cb); 221 if (*pabSha1) 222 { 223 memcpy(*pabSha1, md, cb); 224 *pcbSha1 = cb; 225 226 rc1 = X509_digest(crt, EVP_sha512(), md, &cb); 227 if (rc1 > 0) 228 { 229 *pabSha512 = (uint8_t*)RTMemAlloc(cb); 230 if (*pabSha512) 231 { 232 memcpy(*pabSha512, md, cb); 233 *pcbSha512 = cb; 234 } 235 else 236 rc = VERR_NO_MEMORY; 237 } 238 else 239 rc = VERR_INTERNAL_ERROR; 240 } 241 else 242 rc = VERR_NO_MEMORY; 243 } 244 else 245 rc = VERR_INTERNAL_ERROR; 246 X509_free(crt); 247 } 248 else 249 rc = VERR_INTERNAL_ERROR; 250 BIO_free(cert); 251 } 252 else 253 rc = VERR_INTERNAL_ERROR; 254 255 if (RT_FAILURE(rc)) 256 { 257 RTMemFree(*pabSha512); 231 258 RTMemFree(*pabSha1); 232 return VERR_INTERNAL_ERROR; 233 } 234 *pabSha512 = (uint8_t*)RTMemAlloc(cb); 235 if (!*pabSha512) 236 { 237 RTMemFree(*pabSha512); 238 return VERR_NO_MEMORY; 239 } 240 memcpy(*pabSha512, md, cb); 241 *pcbSha512 = cb; 242 243 return VINF_SUCCESS; 259 } 260 261 return rc; 244 262 } 245 263 … … 320 338 case CURLE_URL_MALFORMAT: 321 339 case CURLE_COULDNT_RESOLVE_HOST: 322 rc = VERR_HTTP_NOT_FOUND; 340 rc = VERR_HTTP_NOT_FOUND; 323 341 break; 324 342 default: -
trunk/src/VBox/Runtime/testcase/tstHttp.cpp
r45339 r45343 45 45 46 46 RTHTTP hHttp; 47 int rc = RTHttpCreate(&hHttp);48 47 char *pszBuf = NULL; 49 48 PRTSTREAM CAFile = NULL; 50 49 50 int rc = RTHttpCreate(&hHttp); 51 51 52 // create certificate file 52 rc = RTStrmOpen(CAFILE_NAME, "w+b", &CAFile); 53 if (RT_SUCCESS(rc)) 54 rc = RTStrmOpen(CAFILE_NAME, "w+b", &CAFile); 53 55 54 56 // fetch root CA certificate (new one, often avoided in cert chains by
Note:
See TracChangeset
for help on using the changeset viewer.