2 * Copyright (C) 2005, 2006, 2008 Free Software Foundation
4 * Author: Simon Josefsson
6 * This file is part of GNUTLS.
8 * GNUTLS is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * GNUTLS is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GNUTLS; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
34 gnutls_certificate_credentials_t x509cred
;
35 const char *file
, *password
;
38 ret
= gnutls_global_init ();
40 fail ("gnutls_global_init failed %d\n", ret
);
42 ret
= gnutls_certificate_allocate_credentials (&x509cred
);
44 fail ("gnutls_certificate_allocate_credentials failed %d\n", ret
);
46 file
= getenv ("PKCS12FILE");
47 password
= getenv ("PKCS12PASSWORD");
50 file
= "pkcs12-decode/client.p12";
54 success ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
56 ret
= gnutls_certificate_set_x509_simple_pkcs12_file (x509cred
,
61 fail ("x509_pkcs12 failed %d: %s\n", ret
, gnutls_strerror (ret
));
63 success ("Read file OK\n");
65 gnutls_certificate_free_credentials (x509cred
);
67 /* try now if we can read correctly from a pkcs12 file that
68 * contains two certificates (one unrelated with key)
70 ret
= gnutls_certificate_allocate_credentials (&x509cred
);
72 fail ("gnutls_certificate_allocate_credentials failed %d\n", ret
);
74 file
= getenv ("PKCS12FILE_2");
75 password
= getenv ("PKCS12PASSWORD_2");
78 file
= "pkcs12-decode/pkcs12_2certs.p12";
82 success ("Reading PKCS#12 blob from `%s' using password `%s'.\n",
84 ret
= gnutls_certificate_set_x509_simple_pkcs12_file (x509cred
,
89 fail ("x509_pkcs12 failed %d: %s\n", ret
, gnutls_strerror (ret
));
91 success ("Read file OK\n");
93 gnutls_certificate_free_credentials (x509cred
);
95 gnutls_global_deinit ();