summaryrefslogtreecommitdiff
path: root/tests/set_pkcs12_cred.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@crystal.(none)>2008-11-05 22:51:45 +0200
committerNikos Mavrogiannopoulos <nmav@crystal.(none)>2008-11-05 22:51:45 +0200
commit126cf449f0239e3c209acd21294f4ca0cb6a5247 (patch)
tree7451b682d6f7a5717cd6f77a4d09ba1632c1411c /tests/set_pkcs12_cred.c
parentea0180b372f3fbc2b6f28b762f9d9b2fb4a8a799 (diff)
downloadgnutls-126cf449f0239e3c209acd21294f4ca0cb6a5247.tar.gz
* Added gnutls_certificate_set_x509_simple_pkcs12_mem
* Made gnutls_certificate_set_x509_simple_pkcs12_file() more advanced. It will return a corresponding certificate and key pair. [The previous version would return the first ones found]. Eliminated memory leaks on error conditions on these functions.
Diffstat (limited to 'tests/set_pkcs12_cred.c')
-rw-r--r--tests/set_pkcs12_cred.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/set_pkcs12_cred.c b/tests/set_pkcs12_cred.c
index 8e292d484b..c0349a24c3 100644
--- a/tests/set_pkcs12_cred.c
+++ b/tests/set_pkcs12_cred.c
@@ -64,5 +64,33 @@ doit (void)
gnutls_certificate_free_credentials (x509cred);
+ /* try now if we can read correctly from a pkcs12 file that
+ * contains two certificates (one unrelated with key)
+ */
+ ret = gnutls_certificate_allocate_credentials (&x509cred);
+ if (ret < 0)
+ fail ("gnutls_certificate_allocate_credentials failed %d\n", ret);
+
+ file = getenv ("PKCS12FILE_2");
+ password = getenv ("PKCS12PASSWORD_2");
+
+ if (!file)
+ file = "pkcs12-decode/pkcs12_2certs.p12";
+ if (!password)
+ password = "";
+
+ success ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
+ file, password);
+ ret = gnutls_certificate_set_x509_simple_pkcs12_file (x509cred,
+ file,
+ GNUTLS_X509_FMT_DER,
+ password);
+ if (ret < 0)
+ fail ("x509_pkcs12 failed %d: %s\n", ret, gnutls_strerror (ret));
+
+ success ("Read file OK\n");
+
+ gnutls_certificate_free_credentials (x509cred);
+
gnutls_global_deinit ();
}