| 316 | */ |
| 317 | |
| 318 | int /* O - Status of call (0 = success) */ |
| 319 | httpCopyCredentials( |
| 320 | http_t *http, /* I - Connection to server */ |
| 321 | cups_array_t **credentials) /* O - Array of credentials */ |
| 322 | { |
| 323 | unsigned count; /* Number of certificates */ |
| 324 | const gnutls_datum_t *certs; /* Certificates */ |
| 325 | |
| 326 | |
| 327 | DEBUG_printf(("httpCopyCredentials(http=%p, credentials=%p)", http, credentials)); |
| 328 | |
| 329 | if (credentials) |
| 330 | *credentials = NULL; |
| 331 | |
| 332 | if (!http || !http->tls || !credentials) |
| 333 | return (-1); |
| 334 | |
| 335 | *credentials = cupsArrayNew(NULL, NULL); |
| 336 | certs = gnutls_certificate_get_peers(http->tls, &count); |
| 337 | |
| 338 | DEBUG_printf(("1httpCopyCredentials: certs=%p, count=%u", certs, count)); |
| 339 | |
| 340 | if (certs && count) |
| 341 | { |
| 342 | while (count > 0) |
| 343 | { |
| 344 | httpAddCredential(*credentials, certs->data, certs->size); |
| 345 | certs ++; |
| 346 | count --; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | return (0); |
| 351 | } |
| 352 | |
| 353 | |
| 354 | /* |
nothing calls this directly
no test coverage detected