1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108
|
/*
neon test suite
Copyright (C) 2002-2025, Joe Orton <joe@manyfish.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
#include "ne_request.h"
#include "ne_socket.h"
#include "ne_ssl.h"
#include "ne_auth.h"
#include "tests.h"
#include "child.h"
#include "utils.h"
#ifndef NE_HAVE_SSL
/* this file shouldn't be built if SSL is not enabled. */
#error SSL not supported
#endif
#include "ne_pkcs11.h"
#define SERVER_CERT "server.cert"
#define CA2_SERVER_CERT "ca2server.pem"
#define CA_CERT "ca/cert.pem"
#define P12_PASSPHRASE "foobar"
#define SERVER_DNAME "Neon QA Dept, Neon Hackers Ltd, " \
"Cambridge, Cambridgeshire, GB"
#define CACERT_DNAME "Random Dept, Neosign, Oakland, California, US"
static char *srcdir = ".";
static char *server_key = NULL;
static ne_ssl_certificate *def_ca_cert = NULL, *def_server_cert;
static ne_ssl_client_cert *def_cli_cert;
static char *nul_cn_fn;
static int check_dname(const ne_ssl_dname *dn, const char *expected,
const char *which);
static int check_cert_dnames(const ne_ssl_certificate *cert,
const char *subject, const char *issuer)
ne_attribute((nonnull (2)));
/* Arguments for running the SSL server */
struct ssl_server_args {
char *cert; /* the server cert to present. */
const char *key; /* server key filename */
const char *response; /* the HTTP response message to send. */
int numreqs; /* number of request/responses to handle over the SSL connection. */
/* client cert handling: */
int require_cc; /* require a client cert if non-NULL */
const char *ca_list; /* file of CA certs to verify client cert against */
int fail_silently; /* exit with success if handshake fails */
/* session caching: */
int cache; /* use the session cache if non-zero */
struct ssl_session {
unsigned char id[128];
size_t len;
} session;
int count; /* internal use. */
/* minimum, maximum version. */
enum ne_ssl_protocol minver, maxver;
};
/* default response string if args->response is NULL */
#define DEF_RESP "HTTP/1.0 200 OK\r\nContent-Length: 0\r\n\r\n"
/* An SSL server inna bun. */
static int ssl_server(ne_socket *sock, void *userdata)
{
struct ssl_server_args *args = userdata;
int ret;
char buf[BUFSIZ];
const char *key;
static ne_ssl_context *ctx = NULL;
if (ctx == NULL) {
ctx = ne_ssl_context_create(NE_SSL_CTX_SERVER);
}
ONV(ctx == NULL, ("could not create SSL context"));
key = args->key ? args->key : server_key;
NE_DEBUG(NE_DBG_HTTP, "SSL server init with keypair (%s, %s).\n",
args->cert, key);
ONV(ne_ssl_context_keypair(ctx, args->cert, key),
("failed to load server keypair: ..."));
if (args->require_cc && !args->ca_list) {
args->ca_list = CA_CERT;
}
ne_ssl_context_set_verify(ctx, args->require_cc,
args->ca_list, args->ca_list);
ret = ne_sock_accept_ssl(sock, ctx);
if (ret && args->fail_silently) {
return 0;
}
ONV(ret, ("SSL accept failed: %s", ne_sock_error(sock)));
args->count++;
/* loop handling requests: */
do {
const char *response = args->response ? args->response : DEF_RESP;
ret = ne_sock_read(sock, buf, BUFSIZ - 1);
if (ret == NE_SOCK_CLOSED)
return 0; /* connection closed by parent; give up. */
ONV(ret < 0, ("SSL read failed (%d): %s", ret,
ne_sock_error(sock)));
buf[ret] = '\0';
NE_DEBUG(NE_DBG_HTTP, "Request over SSL was: [%s]\n", buf);
if (strstr(buf, "Proxy-Authorization:") != NULL) {
NE_DEBUG(NE_DBG_HTTP, "Got Proxy-Auth header over SSL!\n");
response = "HTTP/1.1 500 Client Leaks Credentials\r\n"
"Content-Length: 0\r\n" "\r\n";
}
ONV(ne_sock_fullwrite(sock, response, strlen(response)),
("SSL write failed: %s", ne_sock_error(sock)));
} while (--args->numreqs > 0);
if (args->minver || args->maxver) {
unsigned int vers = ne_sock_getproto(sock);
const char *name = ne_ssl_proto_name(vers);
NE_DEBUG(NE_DBG_HTTP, "ssl: TLS protocol version (%d): [%s]\n",
vers, name);
ONV((args->minver && vers < args->minver)
|| (args->maxver && vers > args->maxver),
("SSL protocol version %d (%s) outside range (%d, %d)",
vers, name, args->minver, args->maxver));
}
if (args->cache) {
unsigned char sessid[128];
size_t len = sizeof sessid;
ONN("could not retrieve session ID",
ne_sock_sessid(sock, sessid, &len));
#ifdef NE_DEBUGGING
{
char *b64 = ne_base64(sessid, len);
NE_DEBUG(NE_DBG_SSL, "ssl: Session id retrieved (%d): [%s]\n",
args->count, b64);
ne_free(b64);
}
#endif
if (args->count == 1) {
/* save the session. */
memcpy(args->session.id, sessid, len);
args->session.len = len;
} else {
/* Compare with stored session. */
ONN("cached session not used",
args->session.len != len
|| memcmp(args->session.id, sessid, len));
}
}
ret = ne_sock_shutdown(sock, NE_SOCK_SEND);
NE_DEBUG(NE_DBG_SSL, "ssl: Shutdown received %d\n", ret);
return 0;
}
#define DEFSESS (ne_session_create("https", "localhost", 7777))
static int make_ssl_session_port(ne_session **sess,
const char *hostname, int port,
server_fn fn, void *userdata)
{
return fakeproxied_session_server(sess, "https", hostname, port,
fn, userdata);
}
static int make_ssl_session(ne_session **sess, const char *hostname,
server_fn fn, void *userdata)
{
return make_ssl_session_port(sess,
hostname ? hostname : "localhost", 7777,
fn, userdata);
}
/* Runs SSL server which will accept 'count' connections, running
* ssl_server as callback with given 'args'. */
static int multi_ssl_session(int count, ne_session **sess,
struct ssl_server_args *args)
{
return fakeproxied_multi_session_server(count, sess, "https",
"localhost",
7777,
ssl_server, args);
}
static int load_and_trust_cert(ne_session *sess, const char *ca_cert)
{
ne_ssl_certificate *ca = ne_ssl_cert_read(ca_cert);
ONV(ca == NULL, ("could not load CA cert `%s'", ca_cert));
ne_ssl_trust_cert(sess, ca);
ne_ssl_cert_free(ca);
return OK;
}
static int make_ssl_request(struct ssl_server_args *args,
const char *ca_cert, const char *hostname,
ne_ssl_verify_fn verify_fn, void *verify_ud)
{
ne_session *sess;
CALL(make_ssl_session(&sess, hostname, ssl_server, args));
if (ca_cert) CALL(load_and_trust_cert(sess, ca_cert));
if (verify_fn) ne_ssl_set_verify(sess, verify_fn, verify_ud);
CALL(any_2xx_request(sess, "/foo"));
return destroy_and_wait(sess);
}
/* Run a request in the given session. */
static int any_ssl_request(ne_session *sess, server_fn fn, void *server_ud,
char *ca_cert,
ne_ssl_verify_fn verify_fn, void *verify_ud)
{
if (ca_cert) {
CALL(load_and_trust_cert(sess, ca_cert));
}
CALL(spawn_server(7777, fn, server_ud));
if (verify_fn)
ne_ssl_set_verify(sess, verify_fn, verify_ud);
ONREQ(any_request(sess, "/foo"));
return await_server();
}
static int init(void)
{
/* take srcdir as argv[1] for VPATH builds. */
if (test_argc > 1) {
srcdir = test_argv[1];
}
/* take srcdir as argv[1]. */
server_key = "server.key";
if (ne_sock_init()) {
t_context("could not initialize socket/SSL library.");
return FAILHARD;
}
def_ca_cert = ne_ssl_cert_read(CA_CERT);
if (def_ca_cert == NULL) {
t_context("couldn't load CA cert %s", CA_CERT);
return FAILHARD;
}
def_server_cert = ne_ssl_cert_read(SERVER_CERT);
if (def_server_cert == NULL) {
t_context("couldn't load server cert %s", SERVER_CERT);
return FAILHARD;
}
/* tests for the encrypted client cert, client.p12 */
def_cli_cert = ne_ssl_clicert_read("client.p12");
if (def_cli_cert == NULL) {
t_context("could not load client.p12");
return FAILHARD;
}
if (!ne_ssl_clicert_encrypted(def_cli_cert)) {
ne_ssl_clicert_free(def_cli_cert);
def_cli_cert = NULL;
t_context("client.p12 is not encrypted!?");
return FAIL;
}
if (ne_ssl_clicert_decrypt(def_cli_cert, P12_PASSPHRASE)) {
ne_ssl_clicert_free(def_cli_cert);
def_cli_cert = NULL;
t_context("failed to decrypt client.p12");
return FAIL;
}
nul_cn_fn = ne_concat(srcdir, "/nulcn.pem", NULL);
return OK;
}
/* just check the result codes of loading server certs. */
static int load_server_certs(void)
{
ne_ssl_certificate *cert;
cert = ne_ssl_cert_read("Makefile");
ONN("invalid CA cert file loaded successfully", cert != NULL);
cert = ne_ssl_cert_read("nonesuch.pem");
ONN("non-existent 'nonesuch.pem' loaded successfully", cert != NULL);
cert = ne_ssl_cert_read("ssigned.pem");
ONN("could not load ssigned.pem", cert == NULL);
ne_ssl_cert_free(cert);
return OK;
}
static int trust_default_ca(void)
{
ne_session *sess = DEFSESS;
ne_ssl_trust_default_ca(sess);
ne_session_destroy(sess);
return OK;
}
#define CC_NAME "Just A Neon Client Cert"
/* Tests for loading client certificates */
static int load_client_cert(void)
{
ne_ssl_client_cert *cc;
const ne_ssl_certificate *cert;
const char *name;
cc = ne_ssl_clicert_read("client.p12");
ONN("could not load client.p12", cc == NULL);
ONN("client.p12 not encrypted!?", !ne_ssl_clicert_encrypted(cc));
name = ne_ssl_clicert_name(cc);
if (name == NULL) {
t_warning("no friendly name given");
} else {
ONV(strcmp(name, CC_NAME), ("friendly name was %s not %s", name, CC_NAME));
}
ONN("failed to decrypt", ne_ssl_clicert_decrypt(cc, P12_PASSPHRASE));
ne_ssl_clicert_free(cc);
cc = ne_ssl_clicert_read("client.p12");
ONN("decrypted client.p12 with incorrect password!?",
ne_ssl_clicert_decrypt(cc, "barfoo") == 0);
ne_ssl_clicert_free(cc);
/* tests for the unencrypted client cert, client2.p12 */
cc = ne_ssl_clicert_read("unclient.p12");
ONN("could not load unencrypted cert unclient.p12", cc == NULL);
ONN("unencrypted cert marked encrypted?", ne_ssl_clicert_encrypted(cc));
cert = ne_ssl_clicert_owner(cc);
ONN("client cert had no certificate", cert == NULL);
CALL(check_dname(ne_ssl_cert_subject(cert),
"Neon Client Cert, Neon Hackers Ltd, "
"Cambridge, Cambridgeshire, GB",
"client cert subject"));
CALL(check_dname(ne_ssl_cert_issuer(cert), CACERT_DNAME,
"client cert issuer"));
ne_ssl_clicert_free(cc);
/* test for ccert without a friendly name, noclient.p12 */
cc = ne_ssl_clicert_read("noclient.p12");
ONN("could not load noclient.p12", cc == NULL);
name = ne_ssl_clicert_name(cc);
ONV(name != NULL, ("noclient.p12 had friendly name `%s'", name));
ne_ssl_clicert_free(cc);
/* test for ccert with a bundled CA. */
cc = ne_ssl_clicert_read("clientca.p12");
ONN("could not load clientca.p12", cc == NULL);
ONN("encrypted cert marked unencrypted?", !ne_ssl_clicert_encrypted(cc));
ONN("could not decrypt clientca.p12",
ne_ssl_clicert_decrypt(cc, P12_PASSPHRASE));
ne_ssl_clicert_free(cc);
/* test for ccert without a private key, nkclient.p12 */
cc = ne_ssl_clicert_read("nkclient.p12");
ONN("did not fail to load clicert without pkey", cc != NULL);
/* test for ccert without a cert, ncclient.p12 */
cc = ne_ssl_clicert_read("ncclient.p12");
ONN("did not fail to load clicert without cert", cc != NULL);
/* tests for loading bogus files. */
cc = ne_ssl_clicert_read("Makefile");
ONN("loaded Makefile as client cert!?", cc != NULL);
/* test for loading nonexistent file. */
cc = ne_ssl_clicert_read("nosuch.pem");
ONN("loaded nonexistent file as client cert!?", cc != NULL);
return OK;
}
static int clicert_import(void)
{
ne_ssl_client_cert *cc;
ne_buffer *buf = ne_buffer_create();
CALL(file_to_buffer("client.p12", buf));
cc = ne_ssl_clicert_import((unsigned char *)buf->data, ne_buffer_size(buf));
ONN("could not import client cert from buffer", cc == NULL);
ONN("failed to decrypt", ne_ssl_clicert_decrypt(cc, P12_PASSPHRASE));
ne_ssl_clicert_free(cc);
ne_buffer_destroy(buf);
return OK;
}
/* Test that 'cert', which is signed by CA_CERT, is accepted
* unconditionally. */
static int accept_signed_cert_for_hostname(char *cert, const char *hostname)
{
struct ssl_server_args args = {cert, 0};
/* no verify callback needed. */
return make_ssl_request(&args, CA_CERT, hostname, NULL, NULL);
}
static int accept_signed_cert(char *cert)
{
return accept_signed_cert_for_hostname(cert, "localhost");
}
static int simple(void)
{
return accept_signed_cert(SERVER_CERT);
}
/* Test read-til-EOF behaviour with SSL. */
static int simple_eof(void)
{
struct ssl_server_args args = {SERVER_CERT, 0};
args.response = "HTTP/1.0 200 OK\r\n"
"Connection: close\r\n"
"\r\n"
"This is a response body, like it or not.";
return make_ssl_request(&args, CA_CERT, NULL, NULL, NULL);
}
static int intermediary(void)
{
struct ssl_server_args args = {CA2_SERVER_CERT, 0};
return make_ssl_request(&args, CA_CERT, NULL, NULL, NULL);
}
static int empty_truncated_eof(void)
{
struct ssl_server_args args = {0};
args.cert = SERVER_CERT;
args.response = "HTTP/1.0 200 OK\r\n" "\r\n";
return make_ssl_request(&args, CA_CERT, NULL, NULL, NULL);
}
/* Server function which just sends a string then EOF. */
static int just_serve_string(ne_socket *sock, void *userdata)
{
const char *str = userdata;
server_send(sock, str, strlen(str));
return 0;
}
/* test for the SSL negotiation failing. */
static int fail_not_ssl(void)
{
ne_session *sess;
int ret;
CALL(make_ssl_session(&sess, NULL, just_serve_string, "Hello, world.\n"));
ret = any_request(sess, "/bar");
ONN("request did not fail", ret != NE_ERROR);
return destroy_and_wait(sess);
}
static int wildcard_match(void)
{
struct ssl_server_args args = {"wildcard.cert", 0};
return make_ssl_request(&args, CA_CERT, "bar.example.com", NULL, NULL);
}
static int wildcard_match_altname(void)
{
struct ssl_server_args args = {"altname9.cert", 0};
return make_ssl_request(&args, CA_CERT, "foo.example.com", NULL, NULL);
}
/* Check that hostname comparisons are not cases-sensitive. */
static int caseless_match(void)
{
return accept_signed_cert("caseless.cert");
}
/* Test that the subjectAltName extension has precedence over the
* commonName attribute */
static int subject_altname(void)
{
return accept_signed_cert("altname1.cert");
}
/* tests for multiple altNames. */
static int two_subject_altname(void)
{
return accept_signed_cert("altname2.cert");
}
static int two_subject_altname2(void)
{
return accept_signed_cert("altname3.cert");
}
/* Test that a subject altname with *only* an eMail entry is
* ignored, and the commonName is used instead. */
static int notdns_altname(void)
{
return accept_signed_cert("altname4.cert");
}
static int ipaddr_altname(void)
{
return accept_signed_cert_for_hostname("altname5.cert", "127.0.0.1");
}
/* test that the *most specific* commonName attribute is used. */
static int multi_commonName(void)
{
return accept_signed_cert("twocn.cert");
}
/* regression test for neon <= 0.23.4 where if commonName was the first
* RDN in the subject DN, it was ignored. */
static int commonName_first(void)
{
return accept_signed_cert("cnfirst.cert");
}
static int check_dname(const ne_ssl_dname *dn, const char *expected,
const char *which)
{
char *dname;
ONV(dn == NULL, ("certificate %s dname was NULL", which));
dname = ne_ssl_readable_dname(dn);
NE_DEBUG(NE_DBG_SSL, "Got dname `%s', expecting `%s'\n", dname, expected);
ONV(!dname || strcmp(dname, expected),
("certificate %s dname was `%s' not `%s'", which, dname, expected));
ne_free(dname);
return 0;
}
/* Check that the readable subject issuer dnames of 'cert' match
* 'subject' and 'issuer' (if non-NULL). */
static int check_cert_dnames(const ne_ssl_certificate *cert,
const char *subject, const char *issuer)
{
ONN("no server certificate presented", cert == NULL);
CALL(check_dname(ne_ssl_cert_subject(cert), subject, "subject"));
return issuer ? check_dname(ne_ssl_cert_issuer(cert), issuer, "issuer") : OK;
}
/* Verify callback which checks that the certificate presented has the
* predetermined subject and issuer DN (as per makekeys.sh). */
static int check_cert(void *userdata, int fs, const ne_ssl_certificate *cert)
{
int *ret = userdata;
if (check_cert_dnames(cert, SERVER_DNAME, CACERT_DNAME) == FAIL)
*ret = -1;
else
*ret = 1;
return 0;
}
/* Check that certificate attributes are passed correctly. */
static int parse_cert(void)
{
struct ssl_server_args args = {SERVER_CERT, 0};
int ret = 0;
/* don't give a CA cert; should force the verify callback to be
* used. */
CALL(make_ssl_request(&args, NULL, NULL, check_cert, &ret));
ONN("cert verification never called", ret == 0);
if (ret == -1)
return FAIL;
return OK;
}
#define WRONGCN_DNAME "Bad Hostname Department, Neon Hackers Ltd, " \
"Cambridge, Cambridgeshire, GB"
/* Check the certificate chain presented against known dnames. */
static int check_chain(void *userdata, int fs, const ne_ssl_certificate *cert)
{
int *ret = userdata;
if (check_cert_dnames(cert, WRONGCN_DNAME, CACERT_DNAME) == FAIL) {
*ret = -1;
return 0;
}
cert = ne_ssl_cert_signedby(cert);
if (cert == NULL) {
t_context("no CA cert in chain");
*ret = -1;
return 0;
}
if (check_cert_dnames(cert, CACERT_DNAME, CACERT_DNAME) == FAIL) {
*ret = -1;
return 0;
}
*ret = 1;
return 0;
}
/* Check that certificate attributes are passed correctly. */
static int parse_chain(void)
{
int ret = 0;
struct ssl_server_args args = {"wrongcn.cert", 0};
args.ca_list = CA_CERT;
/* The cert is signed by the CA but has a CN mismatch, so will
* force the verification callback to be invoked. */
CALL(make_ssl_request(&args, CA_CERT, NULL, check_chain, &ret));
ONN("cert verification never called", ret == 0);
if (ret == -1)
return FAIL;
return OK;
}
static int count_vfy(void *userdata, int fs, const ne_ssl_certificate *c)
{
int *count = userdata;
(*count)++;
return 0;
}
static int no_verify(void)
{
int count = 0;
struct ssl_server_args args = {SERVER_CERT, 0};
CALL(make_ssl_request(&args, CA_CERT, NULL, count_vfy, &count));
ONN("verify callback called unnecessarily", count != 0);
return OK;
}
/* Checks that the verify callback is only called on the first
* connection to the SSL server, and not on subsequent connections. */
static int cache_verify(void)
{
ne_session *sess;
int count = 0;
struct ssl_server_args args = {SERVER_CERT, 0};
CALL(multi_ssl_session(2, &sess, &args));
ne_ssl_set_verify(sess, count_vfy, &count);
ONREQ(any_request(sess, "/foo-alpha"));
ONREQ(any_request(sess, "/foo-beta"));
ONV(count != 1,
("verify callback result not cached: called %d times", count));
ne_session_destroy(sess);
return OK;
}
/* Copy failures into *userdata, and fail verification. */
static int get_failures(void *userdata, int fs, const ne_ssl_certificate *c)
{
int *out = userdata;
*out = fs;
NE_DEBUG(NE_DBG_SSL, "test: fail_ssl_request verify callback - %d\n", fs);
return -1;
}
/* Helper function for expected-to-fail SSL tests.
*
* An SSL server is spawned using 'cert' and 'key' as the key pair.
* The client will trust CA cert 'cacert', and use 'host' as the server
* name. If realhost is non-NULL, this address will be used to connect
* to in favour of host; the server is otherwise identified as 'host'.
* 'msg' must be a substring of the error string.
* 'failures' must equal the failure bitmask passed to the verify
* callback in the client.
* If none of the expected conditions is met, 'errstr' will be
* used in the test failure context.
*/
static int fail_ssl_request_with_error2(char *cert, char *key, char *cacert,
const char *host, const char *realhost,
const char *msg, int failures,
const char *errstr)
{
ne_session *sess;
int gotf = 0, ret;
struct ssl_server_args args = {0};
ne_sock_addr *addr = NULL;
const ne_inet_addr **list = NULL;
args.cert = cert;
args.key = key;
args.fail_silently = 1;
CALL(fakeproxied_session_server(&sess, "https", host, 7777, ssl_server, &args));
if (cacert) {
CALL(load_and_trust_cert(sess, cacert));
}
ne_ssl_set_verify(sess, get_failures, &gotf);
ret = any_request(sess, "/expect-to-fail");
NE_DEBUG(NE_DBG_SSL, "test: fail_ssl_request - request code %d, error: %s\n",
ret, ne_get_error(sess));
ONV(gotf == 0,
("no error in verification callback; request rv %d error string: %s",
ret, ne_get_error(sess)));
ONV(gotf & ~NE_SSL_FAILMASK,
("verification flags %x outside mask %x", gotf, NE_SSL_FAILMASK));
/* check the failure flags were as expected. */
ONV(failures != gotf,
("verification flags were %d not %d", gotf, failures));
/* and check that the request was failed too. */
ONV(ret == NE_OK, ("%s", msg));
ONV(errstr && strstr(ne_get_error(sess), errstr) == NULL,
("unexpected failure message '%s', wanted '%s'",
ne_get_error(sess), errstr));
ne_session_destroy(sess);
if (addr) ne_addr_destroy(addr);
if (list) ne_free(list);
return OK;
}
/* Helper function: run a request using the given self-signed server
* certificate, and expect the request to fail with the given
* verification failure flags. */
static int fail_ssl_request_with_error(char *cert, char *cacert, const char *host,
const char *msg, int failures,
const char *errstr)
{
return fail_ssl_request_with_error2(cert, NULL, cacert, host, NULL,
msg, failures, errstr);
}
/* Helper function: run a request using the given self-signed server
* certificate, and expect the request to fail with the given
* verification failure flags. */
static int fail_ssl_request(char *cert, char *cacert, const char *host,
const char *msg, int failures)
{
return fail_ssl_request_with_error(cert, cacert, host, msg, failures,
NULL);
}
/* Note that the certs used for fail_* are mostly self-signed, so the
* cert is passed as CA cert and server cert to fail_ssl_request. */
/* Check that a certificate with the incorrect commonName attribute is
* flagged as such. */
static int fail_wrongCN(void)
{
return fail_ssl_request_with_error("wrongcn.cert", "ca/cert.pem", "localhost",
"certificate with incorrect CN was accepted",
NE_SSL_IDMISMATCH,
"certificate issued for a different hostname");
}
#define SRCDIR(s) ne_concat(srcdir, "/" s, NULL)
#if 0
static int fail_nul_cn(void)
{
char *key = SRCDIR("nulsrv.key"), *ca = SRCDIR("nulca.pem");
CALL(fail_ssl_request_with_error2(nul_cn_fn, key, ca,
"www.bank.com", "localhost",
"certificate with incorrect CN was accepted",
NE_SSL_IDMISMATCH|NE_SSL_EXPIRED|NE_SSL_BADCHAIN,
"certificate issued for a different hostname"));
ne_free(key);
ne_free(ca);
return OK;
}
static int fail_nul_san(void)
{
char *cert = SRCDIR("nulsan.pem"), *key = SRCDIR("nulsrv.key"),
*ca = SRCDIR("nulca.pem");
CALL(fail_ssl_request_with_error2(cert, key, ca,
"www.bank.com", "localhost",
"certificate with incorrect CN was accepted",
NE_SSL_IDMISMATCH|NE_SSL_EXPIRED|NE_SSL_BADCHAIN,
"certificate issued for a different hostname"));
ne_free(cert);
ne_free(key);
ne_free(ca);
return OK;
}
#endif
/* Check that an expired certificate is flagged as such. */
static int fail_expired(void)
{
return fail_ssl_request_with_error("expired.cert", CA_CERT, "localhost",
"expired certificate was accepted",
NE_SSL_EXPIRED,
"certificate has expired");
}
static int fail_notvalid(void)
{
return fail_ssl_request_with_error("notyet.cert", CA_CERT, "localhost",
"not yet valid certificate was accepted",
NE_SSL_NOTYETVALID,
"certificate is not yet valid");
}
/* Check that a server cert with a random issuer and self-signed cert
* fail with UNTRUSTED. */
static int fail_untrusted_ca(void)
{
return fail_ssl_request_with_error("server.cert", NULL, "localhost",
"untrusted CA.", NE_SSL_UNTRUSTED,
"issuer is not trusted");
}
static int fail_self_signed(void)
{
return fail_ssl_request("ssigned.pem", NULL, "localhost",
"self-signed cert", NE_SSL_UNTRUSTED);
}
/* Test for failure when a server cert is presented which has no
* commonName (and no alt names either). */
static int fail_missing_CN(void)
{
struct ssl_server_args args = {0};
ne_session *sess;
int ret;
args.cert = "missingcn.cert";
CALL(make_ssl_session(&sess, "localhost", ssl_server, &args));
ret = any_request(sess, "/fail-missing-cn");
ONN("request did not fail", ret != NE_ERROR);
ONV(strstr(ne_get_error(sess), "missing commonName attribute") == NULL,
("error string unexpected: %s", ne_get_error(sess)));
return destroy_and_wait(sess);
}
/* test for a bad ipAddress altname */
static int fail_bad_ipaltname(void)
{
return fail_ssl_request("altname6.cert", CA_CERT, "127.0.0.1",
"bad IP altname cert", NE_SSL_IDMISMATCH);
}
/* test for a ipAddress which matched against the hostname as per neon
* 0.24 behaviour. */
static int fail_host_ipaltname(void)
{
return fail_ssl_request("altname5.cert", CA_CERT, "localhost",
"bad IP altname cert", NE_SSL_IDMISMATCH);
}
static int fail_wildcard(void)
{
return fail_ssl_request("altname9.cert", CA_CERT, "localhost",
"subjaltname not honored", NE_SSL_IDMISMATCH);
}
static int fail_wildcard_ip(void)
{
return fail_ssl_request("wildip.cert", CA_CERT, "127.0.0.1",
"wildcard IP", NE_SSL_IDMISMATCH);
}
static int fail_ca_expired(void)
{
return fail_ssl_request_with_error("ca1server.cert", "ca1/cert.pem",
"localhost", "issuer ca expired",
NE_SSL_BADCHAIN,
"bad certificate chain");
}
static int fail_ca_notyetvalid(void)
{
return fail_ssl_request("ca3server.cert", "ca3/cert.pem", "localhost",
"issuer ca not yet valid", NE_SSL_BADCHAIN);
}
/* Test that the SSL session is cached across connections. */
static int session_cache(void)
{
struct ssl_server_args args = {0};
ne_session *sess;
args.cert = SERVER_CERT;
args.cache = 1;
CALL(multi_session_server(&sess, "https", "localhost",
2, ssl_server, &args));
/* This currently fails under OpenSSL with TLSv1.3. */
ne_ssl_set_protovers(sess, NE_SSL_PROTO_UNSPEC,
NE_SSL_PROTO_TLS_1_2);
ne_ssl_trust_cert(sess, def_ca_cert);
ONREQ(any_request(sess, "/req1"));
ONREQ(any_request(sess, "/req2"));
return destroy_and_wait(sess);
}
/* Callback for client_cert_provider; takes a c. cert as userdata and
* registers it. */
static void ccert_provider(void *userdata, ne_session *sess,
const ne_ssl_dname *const *dns, int dncount)
{
const ne_ssl_client_cert *cc = userdata;
ne_ssl_set_clicert(sess, cc);
}
/* Test that the on-demand client cert provider callback is used. */
static int client_cert_provided(void)
{
ne_session *sess = DEFSESS;
ne_ssl_client_cert *cc;
struct ssl_server_args args = {SERVER_CERT, NULL};
args.require_cc = 1;
cc = ne_ssl_clicert_read("client.p12");
ONN("could not load client.p12", cc == NULL);
ONN("could not decrypt client.p12",
ne_ssl_clicert_decrypt(cc, P12_PASSPHRASE));
ne_ssl_provide_clicert(sess, ccert_provider, cc);
CALL(any_ssl_request(sess, ssl_server, &args, CA_CERT,
NULL, NULL));
ne_session_destroy(sess);
ne_ssl_clicert_free(cc);
return OK;
}
#define DN_COUNT 5
static void cc_check_dnames(void *userdata, ne_session *sess,
const ne_ssl_dname *const *dns, int dncount)
{
int n, *ret = userdata;
static const char *expected[DN_COUNT] = {
CACERT_DNAME,
"First Random CA, CAs Ltd., Lincoln, Lincolnshire, GB",
"Second Random CA, CAs Ltd., Falmouth, Cornwall, GB",
"Third Random CA, CAs Ltd., Ipswich, Suffolk, GB",
"Fourth Random CA, CAs Ltd., Norwich, Norfolk, GB"
};
ne_ssl_set_clicert(sess, def_cli_cert);
if (dncount != DN_COUNT) {
t_context("dname count was %d not %d", dncount,
DN_COUNT);
*ret = -1;
return;
}
for (n = 0; n < DN_COUNT; n++) {
char which[5];
sprintf(which, "%d", n);
if (check_dname(dns[n], expected[n], which) == FAIL) {
*ret = -1;
return;
}
}
*ret = 1;
}
/* Test for the list of acceptable dnames sent to the client. */
static int cc_provided_dnames(void)
{
int check = 0;
ne_session *sess = DEFSESS;
struct ssl_server_args args = {SERVER_CERT, NULL};
args.require_cc = 1;
args.ca_list = "calist.pem";
PRECOND(def_cli_cert);
ne_ssl_provide_clicert(sess, cc_check_dnames, &check);
CALL(any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL));
ne_session_destroy(sess);
ONN("provider function not called", check == 0);
return (check == -1) ? FAIL : OK;
}
/* Tests use of a client certificate. */
static int client_cert_pkcs12(void)
{
ne_session *sess = DEFSESS;
struct ssl_server_args args = {SERVER_CERT, NULL};
args.require_cc = 1;
PRECOND(def_cli_cert);
ne_ssl_set_clicert(sess, def_cli_cert);
CALL(any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL));
ne_session_destroy(sess);
return OK;
}
/* Test use of a PKCS#12 cert with an embedded CA cert - fails with <=
* 0.28.3 in GnuTLS build. */
static int client_cert_ca(void)
{
ne_session *sess = DEFSESS;
struct ssl_server_args args = {SERVER_CERT, NULL};
ne_ssl_client_cert *cc;
args.require_cc = 1;
cc = ne_ssl_clicert_read("clientca.p12");
ONN("could not load clientca.p12", cc == NULL);
ONN("encrypted cert marked unencrypted?", !ne_ssl_clicert_encrypted(cc));
ONN("could not decrypt clientca.p12",
ne_ssl_clicert_decrypt(cc, P12_PASSPHRASE));
ne_ssl_set_clicert(sess, cc);
CALL(any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL));
ne_ssl_clicert_free(cc);
ne_session_destroy(sess);
return OK;
}
/* Tests use of an unencrypted client certificate. */
static int ccert_unencrypted(void)
{
ne_session *sess = DEFSESS;
ne_ssl_client_cert *ccert;
struct ssl_server_args args = {SERVER_CERT, NULL};
args.require_cc = 1;
ccert = ne_ssl_clicert_read("unclient.p12");
ONN("could not load unclient.p12", ccert == NULL);
ONN("unclient.p12 was encrypted", ne_ssl_clicert_encrypted(ccert));
ne_ssl_set_clicert(sess, ccert);
CALL(any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL));
ne_ssl_clicert_free(ccert);
ne_session_destroy(sess);
return OK;
}
#define NOCERT_MESSAGE "client certificate was requested"
/* random SSL read may fail like this with TLSv1.3 */
#define NOCERT_ALT "certificate required"
/* Tests for useful error message if a handshake fails where a client
* cert was requested. */
static int no_client_cert(void)
{
ne_session *sess;
struct ssl_server_args args = {SERVER_CERT, NULL};
int ret;
args.require_cc = 1;
args.fail_silently = 1;
CALL(make_ssl_session(&sess, NULL, ssl_server, &args));
ne_ssl_trust_cert(sess, def_ca_cert);
ret = any_request(sess, "/failme");
ONV(ret != NE_ERROR,
("unexpected result %d: %s", ret, ne_get_error(sess)));
ONV(strstr(ne_get_error(sess), NOCERT_MESSAGE) == NULL
&& strstr(ne_get_error(sess), NOCERT_ALT) == NULL,
("error message was '%s', missing '%s'",
ne_get_error(sess), NOCERT_MESSAGE));
reap_server();
ne_session_destroy(sess);
return OK;
}
/* non-zero if a server auth header was received */
static int got_server_auth;
/* Utility function which accepts the 'tunnel' header. */
static void tunnel_header(char *value)
{
got_server_auth = 1;
}
/* Server which acts as a proxy accepting a CONNECT request. */
static int serve_tunnel(ne_socket *sock, void *ud)
{
struct ssl_server_args *args = ud;
/* check for a server auth function */
want_header = "Authorization";
got_header = tunnel_header;
got_server_auth = 0;
/* give the plaintext tunnel reply, acting as the proxy */
CALL(discard_request(sock));
if (got_server_auth) {
SEND_STRING(sock, "HTTP/1.1 500 Leaked Server Auth Creds\r\n"
"Content-Length: 0\r\n" "Server: serve_tunnel\r\n\r\n");
return 0;
} else {
SEND_STRING(sock, "HTTP/1.1 200 OK\r\nServer: serve_tunnel\r\n\r\n");
return ssl_server(sock, args);
}
}
/* neon versions <= 0.21.2 segfault here because ne_sock_close would
* be called twice on the socket after the server cert verification
* fails. */
static int fail_tunnel(void)
{
ne_session *sess = ne_session_create("https", "example.com", 443);
struct ssl_server_args args = {SERVER_CERT, NULL};
ne_session_proxy(sess, "localhost", 7777);
ONN("server cert verification didn't fail",
any_ssl_request(sess, serve_tunnel, &args, CA_CERT,
NULL, NULL) != NE_ERROR);
ne_session_destroy(sess);
return OK;
}
static int proxy_tunnel(void)
{
ne_session *sess = ne_session_create("https", "localhost", 443);
struct ssl_server_args args = {SERVER_CERT, NULL};
ne_session_proxy(sess, "localhost", 7777);
/* CA cert is trusted, so no verify callback should be needed. */
CALL(any_ssl_request(sess, serve_tunnel, &args, CA_CERT,
NULL, NULL));
ne_session_destroy(sess);
return OK;
}
struct tunnel_args {
int iteration;
const char *first_response; /* first CONNECT response. */
const char *second_response; /* second CONNECT response. */
struct ssl_server_args *args;
};
/* Server which acts as a proxy accepting a CONNECT request. */
static int serve_auth_tunnel(ne_socket *sock, void *ud)
{
struct tunnel_args *args = ud;
/* check for a server auth function */
want_header = "Authorization";
got_header = tunnel_header;
got_server_auth = 0;
CALL(discard_request(sock));
if (got_server_auth) {
SEND_STRING(sock, "HTTP/1.1 500 Leaked Server Auth Creds\r\n"
"Content-Length: 0\r\n" "Server: serve_tunnel\r\n\r\n");
return 0;
}
if (args->iteration++ == 0) {
/* give the plaintext tunnel reply, acting as the proxy */
SEND_STRING(sock, args->first_response);
return OK;
}
SEND_STRING(sock, args->second_response);
return ssl_server(sock, args->args);
}
static int apt_creds(void *userdata, const char *realm, int attempt,
char *username, char *password)
{
strcpy(username, "foo");
strcpy(password, "bar");
return attempt;
}
/* Test for using SSL over a CONNECT tunnel via a proxy server which
* requires authentication. Broke briefly between 0.23.x and
* 0.24.0. */
static int auth_proxy_tunnel(void)
{
struct ssl_server_args args = {SERVER_CERT, NULL};
struct tunnel_args tunnel;
ne_session *sess;
tunnel.first_response =
"HTTP/1.0 407 I WANT MORE BISCUITS\r\n"
"Server: auth_proxy_tunnel\r\n"
"Proxy-Authenticate: Basic realm=\"bigbluesea\"\r\n"
"Connection: close\r\n" "\r\n";
tunnel.second_response = "HTTP/1.1 200 OK\r\n"
"Server: auth_proxy_tunnel r2\r\n\r\n";
tunnel.iteration = 0;
tunnel.args = &args;
CALL(proxied_multi_session_server(2, &sess, "https", "localhost", 443,
serve_auth_tunnel, &tunnel));
ne_set_proxy_auth(sess, apt_creds, NULL);
ne_ssl_trust_cert(sess, def_ca_cert);
CALL(any_2xx_request(sess, "/foobar"));
return destroy_and_wait(sess);
}
/* Regression test to check that server credentials aren't sent to the
* proxy in a CONNECT request. */
static int auth_tunnel_creds(void)
{
struct ssl_server_args args = {SERVER_CERT, NULL};
struct tunnel_args tunnel;
ne_session *sess;
args.response = "HTTP/1.1 401 I want a Shrubbery\r\n"
"WWW-Authenticate: Basic realm=\"bigredocean\"\r\n"
"Server: auth_tunnel_creds\r\n" "Content-Length: 0\r\n" "\r\n"
""
"HTTP/1.1 200 OK\r\n\r\n";
tunnel.second_response = "HTTP/1.1 200 OK\r\n\r\n";
tunnel.args = &args;
tunnel.iteration = 1;
CALL(proxied_multi_session_server(2, &sess, "https", "localhost", 443,
serve_auth_tunnel, &tunnel));
ne_set_server_auth(sess, apt_creds, NULL);
ne_ssl_trust_cert(sess, def_ca_cert);
CALL(any_2xx_request(sess, "/foobar"));
CALL(any_2xx_request(sess, "/foobar"));
return destroy_and_wait(sess);
}
static int auth_tunnel_fail(void)
{
ne_session *sess;
int ret;
CALL(proxied_session_server(&sess, "https", "localhost", 7777,
single_serve_string,
"HTTP/1.1 407 Nyaaaaah\r\n"
"Proxy-Authenticate: GaBoogle\r\n"
"Content-Length: 0\r\n"
"\r\n"
"HTTP/1.1 200 OK\r\n"
"Content-Length: 0\r\n"
"\r\n"));
ne_set_proxy_auth(sess, apt_creds, NULL);
/* First request: should fail and the auth failure should
* propagate back to the session error string. */
ret = any_request(sess, "/foo");
ONV(ret != NE_PROXYAUTH, ("bad error code for tunnel failure: %d", ret));
ONV(strstr(ne_get_error(sess), "GaBoogle") == NULL,
("bad error string for tunnel failure: %s", ne_get_error(sess)));
/* Second request must fail to connect, the connection should have
* been closed. */
ret = any_request(sess, "/bar");
ONV(ret != NE_CONNECT,
("second attempt should fail to connect, got: %d", ret));
return destroy_and_wait(sess);
}
/* compare against known digest of notvalid.pem. Via:
* $ openssl x509 -fingerprint -sha1 -noout -in notvalid.pem */
#define THE_DIGEST "cf:5c:95:93:76:c6:3c:01:8b:62:" \
"b1:6f:f7:7f:42:32:ac:e6:69:1b"
static int cert_fingerprint(void)
{
char *fn = ne_concat(srcdir, "/notvalid.pem", NULL);
ne_ssl_certificate *cert = ne_ssl_cert_read(fn);
char digest[60];
ne_free(fn);
ONN("could not load notvalid.pem", cert == NULL);
ONN("failed to digest", ne_ssl_cert_digest(cert, digest));
ne_ssl_cert_free(cert);
ONV(strcmp(digest, THE_DIGEST),
("digest was %s not %s", digest, THE_DIGEST));
return OK;
}
static int cert_hdigests(void)
{
static const struct {
unsigned int flags;
const char *digest;
} ts[] = {
{ NE_HASH_MD5|NE_HASH_COLON, "76:26:eb:db:09:e8:53:5c:79:61:0c:30:3d:77:ed:65" },
{ NE_HASH_MD5, "7626ebdb09e8535c79610c303d77ed65" },
{ NE_HASH_SHA256, "ea4a4f4f08a91a83e841e772171a2befa3f6e576b5cd9f5cd6d12e9683fe89b3" },
{ NE_HASH_SHA512, "35373c533f4000ee9b6173a45eedae732f6c953dcf76f5fba5ffb7be380de559893d0679e94051950be2a5917fa7922fbf50ef10222d5be4eea53ba948cf7703" },
{ 0, NULL }
};
unsigned int n, passed = 0;
char *fn = ne_concat(srcdir, "/notvalid.pem", NULL);
ne_ssl_certificate *cert = ne_ssl_cert_read(fn);
ONN("could not load notvalid.pem", cert == NULL);
for (n = 0; ts[n].flags; n++) {
char *dig = ne_ssl_cert_hdigest(cert, ts[n].flags);
/* Can reasonably for almost any hash (either too modern or
* too old), so what can you do? */
if (dig == NULL) {
t_warning("failed to htdigest with flags %u", ts[n].flags);
continue;
}
NE_DEBUG(NE_DBG_SSL, "ssl: hDigest %u got %s, expected %s\n",
ts[n].flags, dig, ts[n].digest);
ONV(strcmp(dig, ts[n].digest),
("digest was %s not %s", dig, ts[n].digest));
passed++;
ne_free(dig);
}
ONN("no algorithms supported for ne_ssl_cert_hdigest", passed == 0);
ne_ssl_cert_free(cert);
ne_free(fn);
return OK;
}
/* verify that identity of certificate in filename 'fname' is 'identity' */
static int check_identity(const char *fname, const char *identity)
{
ne_ssl_certificate *cert = ne_ssl_cert_read(fname);
const char *id;
ONV(cert == NULL, ("could not read cert `%s'", fname));
id = ne_ssl_cert_identity(cert);
if (identity) {
ONV(id == NULL, ("certificate `%s' had no identity", fname));
ONV(strcmp(id, identity),
("certificate `%s' had identity `%s' not `%s'", fname,
id, identity));
} else {
ONV(id != NULL, ("certificate `%s' had identity `%s' (expected none)",
fname, id));
}
ne_ssl_cert_free(cert);
return OK;
}
/* check certificate identities. */
static int cert_identities(void)
{
static const struct {
const char *fname, *identity;
} certs[] = {
{ "ssigned.pem", "localhost" },
{ "twocn.cert", "localhost" },
{ "altname1.cert", "localhost" },
{ "altname2.cert", "nohost.example.com" },
{ "altname4.cert", "localhost" },
{ "ca4.pem", "fourth.example.com" },
{ NULL, NULL }
};
int n;
for (n = 0; certs[n].fname != NULL; n++)
CALL(check_identity(certs[n].fname, certs[n].identity));
return OK;
}
static int nulcn_identity(void)
{
ne_ssl_certificate *cert = ne_ssl_cert_read(nul_cn_fn);
const char *id;
ONN("could not read nulcn.pem", cert == NULL);
id = ne_ssl_cert_identity(cert);
ONN("embedded NUL byte not quoted",
id != NULL && strcmp(id, "www.bank.com") == 0);
ne_ssl_cert_free(cert);
return OK;
}
static int check_validity(const char *fname,
const char *from, const char *until)
{
char actfrom[NE_SSL_VDATELEN], actuntil[NE_SSL_VDATELEN];
ne_ssl_certificate *cert;
cert = ne_ssl_cert_read(fname);
ONV(cert == NULL, ("could not load cert `%s'", fname));
/* cover all calling combos for nice coverage analysis */
ne_ssl_cert_validity(cert, NULL, NULL);
ne_ssl_cert_validity(cert, actfrom, NULL);
ne_ssl_cert_validity(cert, NULL, actuntil);
ne_ssl_cert_validity(cert, actfrom, actuntil);
ONV(strcmp(actfrom, from),
("%s: start time was `%s' not `%s'", fname, actfrom, from));
ONV(strcmp(actuntil, until),
("%s: end time was `%s' not `%s'", fname, actuntil, until));
ne_ssl_cert_free(cert);
return OK;
}
/* ceritificate validity times. */
static int cert_validity(void)
{
char *cert = ne_concat(srcdir, "/expired.pem", NULL);
CALL(check_validity(cert,
"Mon, 21 Jan 2002 20:39:04 GMT", "Thu, 31 Jan 2002 20:39:04 GMT"));
ne_free(cert);
cert = ne_concat(srcdir, "/notvalid.pem", NULL);
CALL(check_validity(cert,
"Wed, 27 Dec 2023 20:40:29 GMT", "Thu, 28 Dec 2023 20:40:29 GMT"));
ne_free(cert);
return OK;
}
/* dname comparisons. */
static int dname_compare(void)
{
ne_ssl_certificate *ssigned;
const ne_ssl_dname *dn1, *dn2;
dn1 = ne_ssl_cert_subject(def_server_cert);
dn2 = ne_ssl_cert_subject(def_server_cert);
ONN("identical subject names not equal", ne_ssl_dname_cmp(dn1, dn2) != 0);
dn2 = ne_ssl_cert_issuer(def_server_cert);
ONN("issuer and subject names equal for signed cert",
ne_ssl_dname_cmp(dn1, dn2) == 0);
dn1 = ne_ssl_cert_subject(def_ca_cert);
ONN("issuer of signed cert not equal to subject of CA cert",
ne_ssl_dname_cmp(dn1, dn2) != 0);
ssigned = ne_ssl_cert_read("ssigned.pem");
ONN("could not load ssigned.pem", ssigned == NULL);
dn1 = ne_ssl_cert_subject(ssigned);
dn2 = ne_ssl_cert_issuer(ssigned);
ONN("issuer and subject names not equal for self-signed cert",
ne_ssl_dname_cmp(dn1, dn2));
ne_ssl_cert_free(ssigned);
return OK;
}
/* The dname with the UTF-8 encoding of the Unicode string:
* "H<LATIN SMALL LETTER E WITH GRAVE>llo World". */
#define I18N_DNAME "H\xc3\xa8llo World, Neon Hackers Ltd, Cambridge, Cambridgeshire, GB"
/* N.B. t61subj.cert encodes an ISO-8859-1 string in a T61String
* field, which is strictly wrong but the common usage. */
/* tests for ne_ssl_readable_dname */
static int dname_readable(void)
{
struct {
const char *cert;
const char *subjdn, *issuerdn;
} ts[] = {
{ "justmail.cert", "blah@example.com", NULL },
{ "t61subj.cert", I18N_DNAME, NULL },
{ "bmpsubj.cert", I18N_DNAME, NULL },
{ "utf8subj.cert", I18N_DNAME, NULL },
{ "twoou.cert", "First OU Dept, Second OU Dept, Neon Hackers Ltd, "
"Cambridge, Cambridgeshire, GB", NULL }
};
size_t n;
for (n = 0; n < sizeof(ts)/sizeof(ts[0]); n++) {
ne_ssl_certificate *cert = ne_ssl_cert_read(ts[n].cert);
ONV(cert == NULL, ("could not load cert %s", ts[n].cert));
CALL(check_cert_dnames(cert, ts[n].subjdn, ts[n].issuerdn));
ne_ssl_cert_free(cert);
}
return OK;
}
/* test cert comparisons */
static int cert_compare(void)
{
ne_ssl_certificate *c1, *c2;
c1 = ne_ssl_cert_read("server.cert");
c2 = ne_ssl_cert_read("server.cert");
ONN("identical certs don't compare equal", ne_ssl_cert_cmp(c1, c2) != 0);
ONN("identical certs don't compare equal", ne_ssl_cert_cmp(c2, c1) != 0);
ne_ssl_cert_free(c2);
c2 = ne_ssl_cert_read("ssigned.pem");
ONN("different certs don't compare different",
ne_ssl_cert_cmp(c1, c2) == 0);
ONN("different certs don't compare different",
ne_ssl_cert_cmp(c2, c1) == 0);
ne_ssl_cert_free(c2);
ne_ssl_cert_free(c1);
return OK;
}
/* Extract raw base64 string from a PEM file */
static int flatten_pem(const char *fname, char **out)
{
FILE *fp = fopen(fname, "r");
char buf[80];
size_t outlen = 0;
int ignore = 1;
ONV(fp == NULL, ("could not open %s", fname));
*out = NULL;
while (fgets(buf, sizeof buf, fp) != NULL) {
size_t len = strlen(buf) - 1;
if (len < 1) continue;
/* look for the wrapper lines. */
if (strncmp(buf, "-----", 5) == 0) {
ignore = !ignore;
continue;
}
/* ignore until the first wrapper line */
if (ignore) continue;
*out = realloc(*out, outlen + len + 1);
memcpy(*out + outlen, buf, len);
outlen += len;
}
(*out)[outlen] = '\0';
fclose(fp);
return OK;
}
/* check export cert data 'actual' against expected data 'expected */
static int check_exported_data(const char *actual, const char *expected)
{
ONN("could not export cert", actual == NULL);
ONN("export data contained newline",
strchr(actual, '\r') || strchr(actual, '\n'));
ONV(strcmp(actual, expected), ("exported cert differed from expected:\n"
"actual: %s\nexpected: %s",
actual, expected));
return OK;
}
/* Test import and export of certificates. The export format is PEM
* without the line feeds and wrapping; compare against . */
static int import_export(void)
{
char *expected, *actual;
ne_ssl_certificate *cert, *imp;
CALL(flatten_pem("server.cert", &expected));
cert = ne_ssl_cert_read("server.cert");
ONN("could not load server.cert", cert == NULL);
/* export the cert to and compare it with the PEM file */
actual = ne_ssl_cert_export(cert);
CALL(check_exported_data(actual, expected));
/* import the exported cert data, check it looks the same */
imp = ne_ssl_cert_import(actual);
ONN("failed to import exported cert", imp == NULL);
ONN("imported cert was different to original",
ne_ssl_cert_cmp(imp, cert));
/* re-export the imported cert and check that looks the same */
ne_free(actual);
actual = ne_ssl_cert_export(imp);
CALL(check_exported_data(actual, expected));
ne_ssl_cert_free(imp);
/* try importing from bogus data */
imp = ne_ssl_cert_import("!!");
ONN("imported bogus cert from bogus base64", imp != NULL);
imp = ne_ssl_cert_import("aaaa");
ONN("imported bogus cert from valid base64", imp != NULL);
ne_ssl_cert_free(cert);
ne_free(actual);
ne_free(expected);
return OK;
}
/* Test write/read */
static int read_write(void)
{
ne_ssl_certificate *c1, *c2;
c1 = ne_ssl_cert_read("server.cert");
ONN("could not load server.cert", c1 == NULL);
ONN("could not write output.pem", ne_ssl_cert_write(c1, "output.pem"));
ONN("wrote to nonexistent directory",
ne_ssl_cert_write(c1, "nonesuch/output.pem") == 0);
c2 = ne_ssl_cert_read("output.pem");
ONN("could not read output.pem", c2 == NULL);
ONN("read of output.pem differs from original",
ne_ssl_cert_cmp(c2, c1));
ne_ssl_cert_free(c1);
ne_ssl_cert_free(c2);
return OK;
}
/* A verification callback which caches the passed cert. */
static int verify_cache(void *userdata, int fs,
const ne_ssl_certificate *cert)
{
char **cache = userdata;
if (*cache == NULL) {
*cache = ne_ssl_cert_export(cert);
return 0;
} else {
return -1;
}
}
/* Test a common use of the SSL API; cache the server cert across
* sessions. */
static int cache_cert(void)
{
ne_session *sess = DEFSESS;
char *cache = NULL;
ne_ssl_certificate *cert;
struct ssl_server_args args = {0};
args.cert = "ssigned.pem";
args.cache = 1;
ONREQ(any_ssl_request(sess, ssl_server, &args, CA_CERT,
verify_cache, &cache));
ne_session_destroy(sess);
ONN("no cert was cached", cache == NULL);
/* make a real cert */
cert = ne_ssl_cert_import(cache);
ONN("could not import cached cert", cert == NULL);
ne_free(cache);
/* create a new session */
sess = DEFSESS;
/* trust the cert */
ne_ssl_trust_cert(sess, cert);
ne_ssl_cert_free(cert);
/* now, the request should succeed without manual verification */
ONREQ(any_ssl_request(sess, ssl_server, &args, CA_CERT,
NULL, NULL));
ne_session_destroy(sess);
return OK;
}
static int nonssl_trust(void)
{
ne_session *sess = ne_session_create("http", "www.example.com", 80);
ne_ssl_trust_cert(sess, def_ca_cert);
ne_ssl_trust_default_ca(sess);
ne_session_destroy(sess);
return OK;
}
#ifdef HAVE_PAKCHOIS
#define PINMAX (2)
struct pindata {
const char *password[PINMAX];
ne_buffer *trace;
};
/* PIN password provider callback. */
static int pkcs11_pin(void *userdata, int attempt,
const char *slot_descr, const char *token_label,
unsigned int flags, char *pin)
{
struct pindata *data = userdata;
NE_DEBUG(NE_DBG_SSL, "pk11: slot = [%s], token = [%s]\n",
slot_descr, token_label);
ne_buffer_snprintf(data->trace, 200, "pin(%d,%s,%s,%u)\n",
attempt, slot_descr?slot_descr:"[none]",
token_label?token_label:"[none]", flags);
if (attempt < PINMAX && data->password[attempt]) {
strcpy(pin, data->password[attempt]);
return 0;
}
else {
return -1;
}
}
#define SLOT_NSS "NSS User Private Key and Certificate Services"
#define TOKEN_NSS "NSS Certificate DB"
static int nss_pkcs11_test(const char *dbname)
{
ne_session *sess = DEFSESS;
struct ssl_server_args args = {SERVER_CERT, NULL};
ne_ssl_pkcs11_provider *prov;
struct pindata pindata;
int ret;
args.require_cc = 1;
if (access(dbname, R_OK|X_OK)) {
t_warning("NSS required for PKCS#11 testing");
return SKIP;
}
ret = ne_ssl_pkcs11_nss_provider_init(&prov, "softokn3", dbname, NULL,
NULL, NULL);
if (ret) {
if (ret == NE_PK11_NOTIMPL)
t_context("pakchois library required for PKCS#11 support");
else
t_context("could not load NSS softokn3 PKCS#11 provider");
return SKIP;
}
pindata.password[0] = "notfoobar";
pindata.password[1] = "foobar";
pindata.trace = ne_buffer_create();
ne_ssl_pkcs11_provider_pin(prov, pkcs11_pin, &pindata);
ne_ssl_set_pkcs11_provider(sess, prov);
ret = any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL);
ne_session_destroy(sess);
ne_ssl_pkcs11_provider_destroy(prov);
if (ret == OK)
ONCMPN("pin(0," SLOT_NSS "," TOKEN_NSS ",0)\n"
"pin(1," SLOT_NSS "," TOKEN_NSS ",0)\n", pindata.trace->data, "pin callback", "data");
ne_buffer_destroy(pindata.trace);
return ret;
}
static int pkcs11(void)
{
return nss_pkcs11_test("nssdb");
}
static int pkcs11_dsa(void)
{
return nss_pkcs11_test("nssdb-dsa");
}
#endif
static int protovers(void)
{
ne_session *sess = DEFSESS;
struct ssl_server_args args = {SERVER_CERT, NULL};
args.minver = NE_SSL_PROTO_TLS_1_2;
args.maxver = NE_SSL_PROTO_TLS_1_2;
ONV(ne_ssl_set_protovers(sess, args.minver, args.maxver),
("setting TLS protocol version failed: %s", ne_get_error(sess)));
CALL(any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL));
ne_session_destroy(sess);
return OK;
}
static int notifier(void)
{
ne_session *sess = DEFSESS;
struct ssl_server_args args = {SERVER_CERT, NULL};
ne_buffer *buf = ne_buffer_create();
args.minver = NE_SSL_PROTO_TLS_1_2;
args.maxver = NE_SSL_PROTO_TLS_1_2;
ONV(ne_ssl_set_protovers(sess, args.minver, args.maxver),
("setting TLS protocol version failed: %s", ne_get_error(sess)));
ne_set_notifier(sess, sess_notifier, buf);
CALL(any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL));
ONV(strstr(buf->data, "-handshake(TLSv1.2, TLS_") == NULL
&& strstr(buf->data, "-handshake(TLSv1.2, [none]") == NULL,
("missing handshake from notifier: %s", buf->data));
ne_session_destroy(sess);
ne_buffer_destroy(buf);
return OK;
}
#define TEST_URI "./enclient.pem"
static int clicert_uri(void)
{
ne_session *sess;
struct ssl_server_args args = {SERVER_CERT, NULL};
ne_ssl_client_cert *cc;
int ret;
args.require_cc = 1;
cc = ne_ssl_clicert_fromuri(TEST_URI, 0);
if (!cc && errno == ENOTSUP) {
t_context("client certificate URI support not available");
return SKIP;
}
ONV(!cc, ("could not load client certificate URI %s: %s",
TEST_URI, strerror(errno)));
ONN("cc not in encrypted state", !ne_ssl_clicert_encrypted(cc));
ONN("successful decrypt with bad password",
ne_ssl_clicert_decrypt(cc, "not-the-password") == 0);
ONN("unsuccessful decrypt with good password",
ne_ssl_clicert_decrypt(cc, P12_PASSPHRASE) != 0);
sess = DEFSESS;
ne_ssl_set_clicert(sess, cc);
ret = any_ssl_request(sess, ssl_server, &args, CA_CERT, NULL, NULL);
ne_session_destroy(sess);
ne_ssl_clicert_free(cc);
return ret;
}
/* TODO: code paths still to test in cert verification:
* - server cert changes between connections: Mozilla gives
* a "bad MAC decode" error for this; can do better?
* - server presents no certificate (using ADH ciphers)... can
* only really happen if they mess with the SSL_CTX and enable
* ADH cipher manually; but good to check the failure case is
* safe.
* - SSL cert changes between connections; handle as normal & re-verify
* From the SSL book:
* - an early FIN should be returned as a possible truncation attack,
* NOT just an NE_SOCK_CLOSED.
* - unexpected close_notify is an error but not an attack.
* - never attempt session resumption after any aborted connection.
*/
ne_test tests[] = {
T_LEAKY(init),
T(load_server_certs),
T(trust_default_ca),
T(cert_fingerprint),
T(cert_hdigests),
T(cert_identities),
T(cert_validity),
T(cert_compare),
T(dname_compare),
T(dname_readable),
T(import_export),
T(read_write),
T(load_client_cert),
T(clicert_import),
T(simple),
T(simple_eof),
T(empty_truncated_eof),
T(fail_not_ssl),
T(cache_cert),
T(intermediary),
T(client_cert_pkcs12),
T(ccert_unencrypted),
T(client_cert_provided),
T(cc_provided_dnames),
T(no_client_cert),
T(client_cert_ca),
T(parse_cert),
T(parse_chain),
T(no_verify),
T(cache_verify),
T(wildcard_match),
T(wildcard_match_altname),
T(caseless_match),
T(subject_altname),
T(two_subject_altname),
T(two_subject_altname2),
T(notdns_altname),
T(ipaddr_altname),
T(multi_commonName),
T(commonName_first),
T(fail_wrongCN),
T(fail_expired),
T(fail_notvalid),
T(fail_untrusted_ca),
T(fail_self_signed),
T(fail_missing_CN),
T(fail_host_ipaltname),
T(fail_bad_ipaltname),
T(fail_wildcard),
T(fail_wildcard_ip),
T(fail_ca_notyetvalid),
T(fail_ca_expired),
T(nulcn_identity),
#if 0
/* These certs were created with a SHA#1 digest so are rejected by
* modern TLS libraries. */
T(fail_nul_cn),
T(fail_nul_san),
#endif
T(session_cache),
T(fail_tunnel),
T(proxy_tunnel),
T(auth_proxy_tunnel),
T(auth_tunnel_creds),
T(auth_tunnel_fail),
T(protovers),
T(nonssl_trust),
#ifdef HAVE_PAKCHOIS
T(pkcs11),
T_XFAIL(pkcs11_dsa), /* unclear why this fails currently. */
#endif
T(notifier),
T(clicert_uri),
T(NULL)
};
|