test_pem_reading: Test loading a key from a file with multiple PEM data
[openssl.git] / test / pemtest.c
index 8c9e04297a49d22da4264ba46f969a699c58ba1e..444603f253b6727d8c00b7416c344f089551be35 100644 (file)
@@ -28,6 +28,8 @@ static TESTDATA b64_pem_data[] = {
 
 static const char *pemtype = "PEMTESTDATA";
 
+static char *pemfile;
+
 static int test_b64(int idx)
 {
     BIO *b = BIO_new(BIO_s_mem());
@@ -83,9 +85,23 @@ static int test_invalid(void)
     return 1;
 }
 
+static int test_cert_key_cert(void)
+{
+    EVP_PKEY *key;
+
+    if (!TEST_ptr(key = load_pkey_pem(pemfile, NULL)))
+        return 0;
+
+    EVP_PKEY_free(key);
+    return 1;
+}
+
 int setup_tests(void)
 {
+    if (!TEST_ptr(pemfile = test_get_argument(0)))
+        return 0;
     ADD_ALL_TESTS(test_b64, OSSL_NELEM(b64_pem_data));
     ADD_TEST(test_invalid);
+    ADD_TEST(test_cert_key_cert);
     return 1;
 }