| 613 | */ |
| 614 | |
| 615 | size_t // O - Total size of credentials string |
| 616 | httpCredentialsString( |
| 617 | cups_array_t *credentials, // I - Credentials |
| 618 | char *buffer, // I - Buffer |
| 619 | size_t bufsize) // I - Size of buffer |
| 620 | { |
| 621 | http_credential_t *first; // First certificate |
| 622 | X509 *cert; // Certificate |
| 623 | |
| 624 | |
| 625 | DEBUG_printf(("httpCredentialsString(credentials=%p, buffer=%p, bufsize=" CUPS_LLFMT ")", credentials, buffer, CUPS_LLCAST bufsize)); |
| 626 | |
| 627 | if (!buffer) |
| 628 | return (0); |
| 629 | |
| 630 | if (bufsize > 0) |
| 631 | *buffer = '\0'; |
| 632 | |
| 633 | first = (http_credential_t *)cupsArrayFirst(credentials); |
| 634 | cert = http_create_credential(first); |
| 635 | |
| 636 | if (cert) |
| 637 | { |
| 638 | char name[256], // Common name associated with cert |
| 639 | issuer[256]; // Issuer associated with cert |
| 640 | time_t expiration; // Expiration date of cert |
| 641 | const char *sigalg; // Signature algorithm |
| 642 | unsigned char md5_digest[16]; // MD5 result |
| 643 | |
| 644 | |
| 645 | X509_NAME_get_text_by_NID(X509_get_subject_name(cert), NID_commonName, name, sizeof(name)); |
| 646 | X509_NAME_get_text_by_NID(X509_get_issuer_name(cert), NID_commonName, issuer, sizeof(issuer)); |
| 647 | expiration = http_get_date(cert, 1); |
| 648 | |
| 649 | switch (X509_get_signature_nid(cert)) |
| 650 | { |
| 651 | case NID_ecdsa_with_SHA1 : |
| 652 | sigalg = "SHA1WithECDSAEncryption"; |
| 653 | break; |
| 654 | case NID_ecdsa_with_SHA224 : |
| 655 | sigalg = "SHA224WithECDSAEncryption"; |
| 656 | break; |
| 657 | case NID_ecdsa_with_SHA256 : |
| 658 | sigalg = "SHA256WithECDSAEncryption"; |
| 659 | break; |
| 660 | case NID_ecdsa_with_SHA384 : |
| 661 | sigalg = "SHA384WithECDSAEncryption"; |
| 662 | break; |
| 663 | case NID_ecdsa_with_SHA512 : |
| 664 | sigalg = "SHA512WithECDSAEncryption"; |
| 665 | break; |
| 666 | case NID_sha1WithRSAEncryption : |
| 667 | sigalg = "SHA1WithRSAEncryption"; |
| 668 | break; |
| 669 | case NID_sha224WithRSAEncryption : |
| 670 | sigalg = "SHA224WithRSAEncryption"; |
| 671 | break; |
| 672 | case NID_sha256WithRSAEncryption : |
no test coverage detected