summaryrefslogtreecommitdiff
path: root/src/cli.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2014-04-05 09:57:01 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2014-04-05 09:57:01 +0200
commit1e0265b03ac02544bb722edb78c8aad57f5e9de4 (patch)
treef867283e28ae1c4c268b84c0ee7fe3cb23d3dabb /src/cli.c
parent6931967cb2196061cdcacdb1fb04fca3dc56e1c8 (diff)
downloadgnutls-1e0265b03ac02544bb722edb78c8aad57f5e9de4.tar.gz
Allow using the --provider parameter in gnutls-cli and certtool to specify a PKCS #11 module.
Diffstat (limited to 'src/cli.c')
-rw-r--r--src/cli.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/cli.c b/src/cli.c
index c92d7ee04b..a4ed4aac44 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2000-2012 Free Software Foundation, Inc.
+ * Copyright (C) 2000-2014 Free Software Foundation, Inc.
+ * Copyright (C) 2013-2014 Nikos Mavrogiannopoulos
*
* This file is part of GnuTLS.
*
@@ -1615,6 +1616,25 @@ static void init_global_tls_stuff(void)
{
int ret;
+#ifdef ENABLE_PKCS11
+ if (HAVE_OPT(PROVIDER)) {
+ ret = gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
+ if (ret < 0)
+ fprintf(stderr, "pkcs11_init: %s",
+ gnutls_strerror(ret));
+ else {
+ ret =
+ gnutls_pkcs11_add_provider(OPT_ARG(PROVIDER),
+ NULL);
+ if (ret < 0) {
+ fprintf(stderr, "pkcs11_add_provider: %s",
+ gnutls_strerror(ret));
+ exit(1);
+ }
+ }
+ }
+#endif
+
/* X509 stuff */
if (gnutls_certificate_allocate_credentials(&xcred) < 0) {
fprintf(stderr, "Certificate allocation memory error\n");