2 * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
9 #include <openssl/ssl.h>
11 #include "helpers/ssltestlib.h"
12 #include "internal/dane.h"
15 #undef OSSL_NO_USABLE_TLS1_3
16 #if defined(OPENSSL_NO_TLS1_3) \
17 || (defined(OPENSSL_NO_EC) && defined(OPENSSL_NO_DH))
19 * If we don't have ec or dh then there are no built-in groups that are usable
22 # define OSSL_NO_USABLE_TLS1_3
25 static char *certsdir = NULL;
26 static char *rootcert = NULL;
27 static char *cert = NULL;
28 static char *privkey = NULL;
29 static char *cert2 = NULL;
30 static char *privkey2 = NULL;
31 static char *cert448 = NULL;
32 static char *privkey448 = NULL;
33 static char *cert25519 = NULL;
34 static char *privkey25519 = NULL;
35 static OSSL_LIB_CTX *libctx = NULL;
36 static OSSL_PROVIDER *defctxnull = NULL;
38 static const unsigned char cert_type_rpk[] = { TLSEXT_cert_type_rpk, TLSEXT_cert_type_x509 };
39 static const unsigned char SID_CTX[] = { 'r', 'p', 'k' };
41 static int rpk_verify_client_cb(int ok, X509_STORE_CTX *ctx)
43 int err = X509_STORE_CTX_get_error(ctx);
45 if (X509_STORE_CTX_get0_rpk(ctx) != NULL) {
46 if (err != X509_V_OK) {
47 TEST_info("rpk_verify_client_cb: ok=%d err=%d", ok, err);
53 static int rpk_verify_server_cb(int ok, X509_STORE_CTX *ctx)
55 int err = X509_STORE_CTX_get_error(ctx);
57 if (X509_STORE_CTX_get0_rpk(ctx) != NULL) {
58 if (err != X509_V_OK) {
59 TEST_info("rpk_verify_server_cb: ok=%d err=%d", ok, err);
68 * (2) server_cert_type RPK off/on for server
69 * (2) client_cert_type RPK off/on for server
70 * (2) server_cert_type RPK off/on for client
71 * (2) client_cert_type RPK off/on for client
72 * (4) RSA vs ECDSA vs Ed25519 vs Ed448 certificates
73 * (2) TLSv1.2 vs TLSv1.3
76 * idx = 0 - is the normal success case, certificate, single peer key
77 * idx = 1 - only a private key
78 * idx = 2 - add client authentication
79 * idx = 3 - add second peer key (rootcert.pem)
80 * idx = 4 - add second peer key (different, RSA or ECDSA)
81 * idx = 5 - reverse peer keys (rootcert.pem, different order)
82 * idx = 6 - reverse peer keys (RSA or ECDSA, different order)
83 * idx = 7 - expects failure due to mismatched key (RSA or ECDSA)
84 * idx = 8 - expects failure due to no configured key on client
85 * idx = 9 - add client authentication (PHA)
86 * idx = 10 - add client authentication (privake key only)
87 * idx = 11 - simple resumption
88 * idx = 12 - simple resumption, no ticket
89 * idx = 13 - resumption with client authentication
90 * idx = 14 - resumption with client authentication, no ticket
91 * idx = 15 - like 0, but use non-default libctx
93 * 16 * 2 * 4 * 2 * 2 * 2 * 2 = 2048 tests
95 static int test_rpk(int idx)
98 # define RPK_DIMS (2 * 4 * 2 * 2 * 2 * 2)
99 SSL_CTX *cctx = NULL, *sctx = NULL;
100 SSL *clientssl = NULL, *serverssl = NULL;
101 EVP_PKEY *pkey = NULL, *other_pkey = NULL, *root_pkey = NULL;
102 X509 *x509 = NULL, *other_x509 = NULL, *root_x509 = NULL;
103 int testresult = 0, ret, expected = 1;
104 int client_expected = X509_V_OK;
107 char *cert_file = NULL;
108 char *privkey_file = NULL;
109 char *other_cert_file = NULL;
110 SSL_SESSION *client_sess = NULL;
111 SSL_SESSION *server_sess = NULL;
112 int idx_server_server_rpk, idx_server_client_rpk;
113 int idx_client_server_rpk, idx_client_client_rpk;
114 int idx_cert, idx_prot;
117 long server_verify_result = 0;
118 long client_verify_result = 0;
119 OSSL_LIB_CTX *test_libctx = NULL;
121 if (!TEST_int_le(idx, RPK_TESTS * RPK_DIMS))
124 idx_server_server_rpk = idx / (RPK_TESTS * 2 * 4 * 2 * 2 * 2);
125 idx %= RPK_TESTS * 2 * 4 * 2 * 2 * 2;
126 idx_server_client_rpk = idx / (RPK_TESTS * 2 * 4 * 2 * 2);
127 idx %= RPK_TESTS * 2 * 4 * 2 * 2;
128 idx_client_server_rpk = idx / (RPK_TESTS * 2 * 4 * 2);
129 idx %= RPK_TESTS * 2 * 4 * 2;
130 idx_client_client_rpk = idx / (RPK_TESTS * 2 * 4);
131 idx %= RPK_TESTS * 2 * 4;
132 idx_cert = idx / (RPK_TESTS * 2);
133 idx %= RPK_TESTS * 2;
134 idx_prot = idx / RPK_TESTS;
137 /* Load "root" cert/pubkey */
138 root_x509 = load_cert_pem(rootcert, NULL);
139 if (!TEST_ptr(root_x509))
141 root_pkey = X509_get0_pubkey(root_x509);
142 if (!TEST_ptr(root_pkey))
149 privkey_file = privkey;
150 other_cert_file = cert2;
152 #ifndef OPENSSL_NO_ECDSA
156 privkey_file = privkey2;
157 other_cert_file = cert;
162 privkey_file = privkey448;
163 other_cert_file = cert;
167 cert_file = cert25519;
168 privkey_file = privkey25519;
169 other_cert_file = cert;
173 testresult = TEST_skip("EDCSA disabled");
176 /* Load primary cert */
177 x509 = load_cert_pem(cert_file, NULL);
180 pkey = X509_get0_pubkey(x509);
181 /* load other cert */
182 other_x509 = load_cert_pem(other_cert_file, NULL);
183 if (!TEST_ptr(other_x509))
185 other_pkey = X509_get0_pubkey(other_x509);
186 #ifdef OPENSSL_NO_ECDSA
187 /* Can't get other_key if it's ECDSA */
188 if (other_pkey == NULL && idx_cert == 0
189 && (idx == 4 || idx == 6 || idx == 7)) {
190 testresult = TEST_skip("EDCSA disabled");
197 #ifdef OSSL_NO_USABLE_TLS1_3
198 testresult = TEST_skip("TLSv1.3 disabled");
201 tls_version = TLS1_3_VERSION;
205 #ifdef OPENSSL_NO_TLS1_2
206 testresult = TEST_skip("TLSv1.2 disabled");
209 tls_version = TLS1_2_VERSION;
217 test_libctx = libctx;
218 defctxnull = OSSL_PROVIDER_load(NULL, "null");
219 if (!TEST_ptr(defctxnull))
222 if (!TEST_true(create_ssl_ctx_pair(test_libctx,
223 TLS_server_method(), TLS_client_method(),
224 tls_version, tls_version,
225 &sctx, &cctx, NULL, NULL)))
228 if (idx_server_server_rpk)
229 if (!TEST_true(SSL_CTX_set1_server_cert_type(sctx, cert_type_rpk, sizeof(cert_type_rpk))))
231 if (idx_server_client_rpk)
232 if (!TEST_true(SSL_CTX_set1_client_cert_type(sctx, cert_type_rpk, sizeof(cert_type_rpk))))
234 if (idx_client_server_rpk)
235 if (!TEST_true(SSL_CTX_set1_server_cert_type(cctx, cert_type_rpk, sizeof(cert_type_rpk))))
237 if (idx_client_client_rpk)
238 if (!TEST_true(SSL_CTX_set1_client_cert_type(cctx, cert_type_rpk, sizeof(cert_type_rpk))))
240 if (!TEST_true(SSL_CTX_set_session_id_context(sctx, SID_CTX, sizeof(SID_CTX))))
242 if (!TEST_true(SSL_CTX_set_session_id_context(cctx, SID_CTX, sizeof(SID_CTX))))
245 if (!TEST_int_gt(SSL_CTX_dane_enable(sctx), 0))
247 if (!TEST_int_gt(SSL_CTX_dane_enable(cctx), 0))
251 SSL_CTX_set_verify(cctx, SSL_VERIFY_PEER, rpk_verify_client_cb);
253 if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
257 if (!TEST_int_gt(SSL_dane_enable(serverssl, NULL), 0))
259 if (!TEST_int_gt(SSL_dane_enable(clientssl, "example.com"), 0))
262 /* Set private key and certificate */
263 if (!TEST_int_eq(SSL_use_PrivateKey_file(serverssl, privkey_file, SSL_FILETYPE_PEM), 1))
265 /* Only a private key */
267 if (idx_server_server_rpk == 0 || idx_client_server_rpk == 0)
270 /* Add certificate */
271 if (!TEST_int_eq(SSL_use_certificate_file(serverssl, cert_file, SSL_FILETYPE_PEM), 1))
273 if (!TEST_int_eq(SSL_check_private_key(serverssl), 1))
279 if (!TEST_true(idx < RPK_TESTS))
283 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
287 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
291 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
293 if (!TEST_true(SSL_add_expected_rpk(serverssl, pkey)))
295 /* Use the same key for client auth */
296 if (!TEST_int_eq(SSL_use_PrivateKey_file(clientssl, privkey_file, SSL_FILETYPE_PEM), 1))
298 if (!TEST_int_eq(SSL_use_certificate_file(clientssl, cert_file, SSL_FILETYPE_PEM), 1))
300 if (!TEST_int_eq(SSL_check_private_key(clientssl), 1))
302 SSL_set_verify(serverssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, rpk_verify_server_cb);
306 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
308 if (!TEST_true(SSL_add_expected_rpk(clientssl, root_pkey)))
312 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
314 if (!TEST_true(SSL_add_expected_rpk(clientssl, other_pkey)))
318 if (!TEST_true(SSL_add_expected_rpk(clientssl, root_pkey)))
320 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
324 if (!TEST_true(SSL_add_expected_rpk(clientssl, other_pkey)))
326 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
330 if (idx_server_server_rpk == 1 && idx_client_server_rpk == 1)
331 client_expected = -1;
332 if (!TEST_true(SSL_add_expected_rpk(clientssl, other_pkey)))
334 client_verify_result = X509_V_ERR_DANE_NO_MATCH;
337 if (idx_server_server_rpk == 1 && idx_client_server_rpk == 1)
338 client_expected = -1;
340 client_verify_result = X509_V_ERR_RPK_UNTRUSTED;
343 if (tls_version != TLS1_3_VERSION) {
344 testresult = TEST_skip("PHA requires TLSv1.3");
347 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
349 if (!TEST_true(SSL_add_expected_rpk(serverssl, pkey)))
351 /* Use the same key for client auth */
352 if (!TEST_int_eq(SSL_use_PrivateKey_file(clientssl, privkey_file, SSL_FILETYPE_PEM), 1))
354 if (!TEST_int_eq(SSL_use_certificate_file(clientssl, cert_file, SSL_FILETYPE_PEM), 1))
356 if (!TEST_int_eq(SSL_check_private_key(clientssl), 1))
358 SSL_set_verify(serverssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_POST_HANDSHAKE, rpk_verify_server_cb);
359 SSL_set_post_handshake_auth(clientssl, 1);
363 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
365 if (!TEST_true(SSL_add_expected_rpk(serverssl, pkey)))
367 /* Use the same key for client auth */
368 if (!TEST_int_eq(SSL_use_PrivateKey_file(clientssl, privkey_file, SSL_FILETYPE_PEM), 1))
370 /* Since there's no cert, this is expected to fail without RPK support */
371 if (!idx_server_client_rpk || !idx_client_client_rpk)
373 SSL_set_verify(serverssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, rpk_verify_server_cb);
377 if (!idx_server_server_rpk || !idx_client_server_rpk) {
378 testresult = TEST_skip("Only testing resumption with server RPK");
381 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
386 if (!idx_server_server_rpk || !idx_client_server_rpk) {
387 testresult = TEST_skip("Only testing resumption with server RPK");
390 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
392 SSL_set_options(serverssl, SSL_OP_NO_TICKET);
393 SSL_set_options(clientssl, SSL_OP_NO_TICKET);
397 if (!idx_server_server_rpk || !idx_client_server_rpk) {
398 testresult = TEST_skip("Only testing resumption with server RPK");
401 if (!idx_server_client_rpk || !idx_client_client_rpk) {
402 testresult = TEST_skip("Only testing client authentication resumption with client RPK");
405 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
407 if (!TEST_true(SSL_add_expected_rpk(serverssl, pkey)))
409 /* Use the same key for client auth */
410 if (!TEST_int_eq(SSL_use_PrivateKey_file(clientssl, privkey_file, SSL_FILETYPE_PEM), 1))
412 if (!TEST_int_eq(SSL_use_certificate_file(clientssl, cert_file, SSL_FILETYPE_PEM), 1))
414 if (!TEST_int_eq(SSL_check_private_key(clientssl), 1))
416 SSL_set_verify(serverssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, rpk_verify_server_cb);
421 if (!idx_server_server_rpk || !idx_client_server_rpk) {
422 testresult = TEST_skip("Only testing resumption with server RPK");
425 if (!idx_server_client_rpk || !idx_client_client_rpk) {
426 testresult = TEST_skip("Only testing client authentication resumption with client RPK");
429 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
431 if (!TEST_true(SSL_add_expected_rpk(serverssl, pkey)))
433 /* Use the same key for client auth */
434 if (!TEST_int_eq(SSL_use_PrivateKey_file(clientssl, privkey_file, SSL_FILETYPE_PEM), 1))
436 if (!TEST_int_eq(SSL_use_certificate_file(clientssl, cert_file, SSL_FILETYPE_PEM), 1))
438 if (!TEST_int_eq(SSL_check_private_key(clientssl), 1))
440 SSL_set_verify(serverssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, rpk_verify_server_cb);
441 SSL_set_options(serverssl, SSL_OP_NO_TICKET);
442 SSL_set_options(clientssl, SSL_OP_NO_TICKET);
447 if (!TEST_true(SSL_add_expected_rpk(clientssl, pkey)))
452 ret = create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE);
453 if (!TEST_int_eq(expected, ret))
456 /* Make sure client gets RPK or certificate as configured */
458 if (idx_server_server_rpk && idx_client_server_rpk) {
459 if (!TEST_long_eq(SSL_get_verify_result(clientssl), client_verify_result))
461 if (!TEST_ptr(SSL_get0_peer_rpk(clientssl)))
463 if (!TEST_int_eq(SSL_get_negotiated_server_cert_type(serverssl), TLSEXT_cert_type_rpk))
465 if (!TEST_int_eq(SSL_get_negotiated_server_cert_type(clientssl), TLSEXT_cert_type_rpk))
468 if (!TEST_ptr(SSL_get0_peer_certificate(clientssl)))
470 if (!TEST_int_eq(SSL_get_negotiated_server_cert_type(serverssl), TLSEXT_cert_type_x509))
472 if (!TEST_int_eq(SSL_get_negotiated_server_cert_type(clientssl), TLSEXT_cert_type_x509))
478 /* Make PHA happen... */
479 if (!TEST_true(SSL_verify_client_post_handshake(serverssl)))
481 if (!TEST_true(SSL_do_handshake(serverssl)))
483 if (!TEST_int_le(SSL_read(clientssl, NULL, 0), 0))
485 if (!TEST_int_le(SSL_read(serverssl, NULL, 0), 0))
489 /* Make sure server gets an RPK or certificate as configured */
491 if (idx_server_client_rpk && idx_client_client_rpk) {
492 if (!TEST_long_eq(SSL_get_verify_result(serverssl), server_verify_result))
494 if (!TEST_ptr(SSL_get0_peer_rpk(serverssl)))
496 if (!TEST_int_eq(SSL_get_negotiated_client_cert_type(serverssl), TLSEXT_cert_type_rpk))
498 if (!TEST_int_eq(SSL_get_negotiated_client_cert_type(clientssl), TLSEXT_cert_type_rpk))
501 /* only if connection is expected to succeed */
502 if (expected == 1 && !TEST_ptr(SSL_get0_peer_certificate(serverssl)))
504 if (!TEST_int_eq(SSL_get_negotiated_client_cert_type(serverssl), TLSEXT_cert_type_x509))
506 if (!TEST_int_eq(SSL_get_negotiated_client_cert_type(clientssl), TLSEXT_cert_type_x509))
512 EVP_PKEY *client_pkey = NULL;
513 EVP_PKEY *server_pkey = NULL;
515 if (!TEST_ptr((client_sess = SSL_get1_session(clientssl)))
516 || !TEST_ptr((client_pkey = SSL_SESSION_get0_peer_rpk(client_sess))))
519 if (!TEST_ptr((server_sess = SSL_get1_session(serverssl)))
520 || !TEST_ptr((server_pkey = SSL_SESSION_get0_peer_rpk(server_sess))))
523 SSL_shutdown(clientssl);
524 SSL_shutdown(serverssl);
527 serverssl = clientssl = NULL;
529 if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl,
531 || !TEST_true(SSL_set_session(clientssl, client_sess)))
534 /* Set private key (and maybe certificate) */
535 if (!TEST_int_eq(SSL_use_PrivateKey_file(serverssl, privkey_file, SSL_FILETYPE_PEM), 1))
537 if (!TEST_int_eq(SSL_use_certificate_file(serverssl, cert_file, SSL_FILETYPE_PEM), 1))
539 if (!TEST_int_eq(SSL_check_private_key(serverssl), 1))
541 if (!TEST_int_gt(SSL_dane_enable(serverssl, "example.com"), 0))
543 if (!TEST_int_gt(SSL_dane_enable(clientssl, "example.com"), 0))
550 if (!TEST_true(SSL_add_expected_rpk(clientssl, client_pkey)))
554 if (!TEST_true(SSL_add_expected_rpk(clientssl, client_pkey)))
556 SSL_set_options(clientssl, SSL_OP_NO_TICKET);
557 SSL_set_options(serverssl, SSL_OP_NO_TICKET);
560 if (!TEST_true(SSL_add_expected_rpk(clientssl, client_pkey)))
562 if (!TEST_true(SSL_add_expected_rpk(serverssl, server_pkey)))
564 /* Use the same key for client auth */
565 if (!TEST_int_eq(SSL_use_PrivateKey_file(clientssl, privkey_file, SSL_FILETYPE_PEM), 1))
567 if (!TEST_int_eq(SSL_use_certificate_file(clientssl, cert_file, SSL_FILETYPE_PEM), 1))
569 if (!TEST_int_eq(SSL_check_private_key(clientssl), 1))
571 SSL_set_verify(serverssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, rpk_verify_server_cb);
574 if (!TEST_true(SSL_add_expected_rpk(clientssl, client_pkey)))
576 if (!TEST_true(SSL_add_expected_rpk(serverssl, server_pkey)))
578 /* Use the same key for client auth */
579 if (!TEST_int_eq(SSL_use_PrivateKey_file(clientssl, privkey_file, SSL_FILETYPE_PEM), 1))
581 if (!TEST_int_eq(SSL_use_certificate_file(clientssl, cert_file, SSL_FILETYPE_PEM), 1))
583 if (!TEST_int_eq(SSL_check_private_key(clientssl), 1))
585 SSL_set_verify(serverssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, rpk_verify_server_cb);
586 SSL_set_options(serverssl, SSL_OP_NO_TICKET);
587 SSL_set_options(clientssl, SSL_OP_NO_TICKET);
591 ret = create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE);
592 if (!TEST_int_eq(expected, ret))
594 verify = SSL_get_verify_result(clientssl);
595 if (!TEST_int_eq(client_expected, verify))
597 if (!TEST_true(SSL_session_reused(clientssl)))
600 if (!TEST_ptr(SSL_get0_peer_rpk(clientssl)))
602 if (!TEST_int_eq(SSL_get_negotiated_server_cert_type(serverssl), TLSEXT_cert_type_rpk))
604 if (!TEST_int_eq(SSL_get_negotiated_server_cert_type(clientssl), TLSEXT_cert_type_rpk))
608 if (!TEST_ptr(SSL_get0_peer_rpk(serverssl)))
610 if (!TEST_int_eq(SSL_get_negotiated_client_cert_type(serverssl), TLSEXT_cert_type_rpk))
612 if (!TEST_int_eq(SSL_get_negotiated_client_cert_type(clientssl), TLSEXT_cert_type_rpk))
620 OSSL_PROVIDER_unload(defctxnull);
622 SSL_SESSION_free(client_sess);
623 SSL_SESSION_free(server_sess);
629 X509_free(other_x509);
630 X509_free(root_x509);
632 if (testresult == 0) {
633 TEST_info("idx_ss_rpk=%d, idx_sc_rpk=%d, idx_cs_rpk=%d, idx_cc_rpk=%d, idx_cert=%d, idx_prot=%d, idx=%d",
634 idx_server_server_rpk, idx_server_client_rpk,
635 idx_client_server_rpk, idx_client_client_rpk,
636 idx_cert, idx_prot, idx);
641 static int test_rpk_api(void)
644 SSL_CTX *cctx = NULL, *sctx = NULL;
645 unsigned char cert_type_dups[] = { TLSEXT_cert_type_rpk,
646 TLSEXT_cert_type_x509,
647 TLSEXT_cert_type_x509 };
648 unsigned char cert_type_bad[] = { 0xFF };
649 unsigned char cert_type_extra[] = { TLSEXT_cert_type_rpk,
650 TLSEXT_cert_type_x509,
652 unsigned char cert_type_unsup[] = { TLSEXT_cert_type_pgp,
653 TLSEXT_cert_type_1609dot2 };
654 unsigned char cert_type_just_x509[] = { TLSEXT_cert_type_x509 };
655 unsigned char cert_type_just_rpk[] = { TLSEXT_cert_type_rpk };
657 if (!TEST_true(create_ssl_ctx_pair(NULL,
658 TLS_server_method(), TLS_client_method(),
659 TLS1_2_VERSION, TLS1_2_VERSION,
660 &sctx, &cctx, NULL, NULL)))
663 if (!TEST_false(SSL_CTX_set1_server_cert_type(sctx, cert_type_dups, sizeof(cert_type_dups))))
666 if (!TEST_false(SSL_CTX_set1_server_cert_type(sctx, cert_type_bad, sizeof(cert_type_bad))))
669 if (!TEST_false(SSL_CTX_set1_server_cert_type(sctx, cert_type_extra, sizeof(cert_type_extra))))
672 if (!TEST_false(SSL_CTX_set1_server_cert_type(sctx, cert_type_unsup, sizeof(cert_type_unsup))))
675 if (!TEST_true(SSL_CTX_set1_server_cert_type(sctx, cert_type_just_x509, sizeof(cert_type_just_x509))))
678 if (!TEST_true(SSL_CTX_set1_server_cert_type(sctx, cert_type_just_rpk, sizeof(cert_type_just_rpk))))
687 OPT_TEST_DECLARE_USAGE("certdir\n")
689 int setup_tests(void)
691 if (!test_skip_common_options()) {
692 TEST_error("Error parsing test options\n");
696 if (!TEST_ptr(certsdir = test_get_argument(0)))
699 rootcert = test_mk_file_path(certsdir, "rootcert.pem");
700 if (rootcert == NULL)
703 cert = test_mk_file_path(certsdir, "servercert.pem");
707 privkey = test_mk_file_path(certsdir, "serverkey.pem");
711 cert2 = test_mk_file_path(certsdir, "server-ecdsa-cert.pem");
715 privkey2 = test_mk_file_path(certsdir, "server-ecdsa-key.pem");
716 if (privkey2 == NULL)
719 cert448 = test_mk_file_path(certsdir, "server-ed448-cert.pem");
723 privkey448 = test_mk_file_path(certsdir, "server-ed448-key.pem");
724 if (privkey2 == NULL)
727 cert25519 = test_mk_file_path(certsdir, "server-ed25519-cert.pem");
731 privkey25519 = test_mk_file_path(certsdir, "server-ed25519-key.pem");
732 if (privkey2 == NULL)
735 libctx = OSSL_LIB_CTX_new();
739 ADD_TEST(test_rpk_api);
740 ADD_ALL_TESTS(test_rpk, RPK_TESTS * RPK_DIMS);
747 void cleanup_tests(void)
749 OPENSSL_free(rootcert);
751 OPENSSL_free(privkey);
753 OPENSSL_free(privkey2);
754 OPENSSL_free(cert448);
755 OPENSSL_free(privkey448);
756 OPENSSL_free(cert25519);
757 OPENSSL_free(privkey25519);
758 OSSL_LIB_CTX_free(libctx);