Changeset 45339 in vbox for trunk/src/VBox/Runtime/common/misc/http.cpp
- Timestamp:
- Apr 4, 2013 2:54:50 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/http.cpp
r45331 r45339 37 37 38 38 #include <curl/curl.h> 39 #include <openssl/ssl.h> 39 40 #include "internal/magics.h" 40 41 … … 195 196 if (CURL_FAILED(rcCurl)) 196 197 return VERR_INVALID_PARAMETER; 198 199 return VINF_SUCCESS; 200 } 201 202 RTR3DECL(int) RTHttpCertDigest(RTHTTP hHttp, char *pcszCert, size_t cbCert, 203 uint8_t **pabSha1, size_t *pcbSha1, 204 uint8_t **pabSha512, size_t *pcbSha512) 205 { 206 BIO *cert = BIO_new_mem_buf(pcszCert, 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 { 231 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; 197 242 198 243 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.