summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-11 20:40:38 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-11-11 20:45:35 +0100
commit3d98785df958a2061dd9056bb38cc318be202b33 (patch)
tree3c13b9ae71665227908c4f15362b4ae2deac9e13 /src
parente146798cb567e3a2f74d824b042c9911364b404c (diff)
downloadgnutls-3d98785df958a2061dd9056bb38cc318be202b33.tar.gz
The pubkey-info option can be combined with the load-privkey to extract the public key of a private key.
Diffstat (limited to 'src')
-rw-r--r--src/certtool-args.c2
-rw-r--r--src/certtool-args.def2
-rw-r--r--src/certtool-args.h2
-rw-r--r--src/certtool.c22
4 files changed, 20 insertions, 8 deletions
diff --git a/src/certtool-args.c b/src/certtool-args.c
index 016c7865d4..26d78f9178 100644
--- a/src/certtool-args.c
+++ b/src/certtool-args.c
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (certtool-args.c)
*
- * It has been AutoGen-ed November 8, 2012 at 11:35:51 PM by AutoGen 5.16
+ * It has been AutoGen-ed November 11, 2012 at 08:37:40 PM by AutoGen 5.16
* From the definitions certtool-args.def
* and the template file options
*
diff --git a/src/certtool-args.def b/src/certtool-args.def
index 23c9d4fa40..480c16eb6c 100644
--- a/src/certtool-args.def
+++ b/src/certtool-args.def
@@ -235,7 +235,7 @@ flag = {
flag = {
name = pubkey-info;
descrip = "Print information on a public key";
- doc = "";
+ doc = "The option combined with --load-pubkey, --load-privkey and --load-certificate will extract the public key of the object in question.";
};
flag = {
diff --git a/src/certtool-args.h b/src/certtool-args.h
index d10c14de55..6c0b9449c2 100644
--- a/src/certtool-args.h
+++ b/src/certtool-args.h
@@ -2,7 +2,7 @@
*
* DO NOT EDIT THIS FILE (certtool-args.h)
*
- * It has been AutoGen-ed November 8, 2012 at 11:35:51 PM by AutoGen 5.16
+ * It has been AutoGen-ed November 11, 2012 at 08:37:40 PM by AutoGen 5.16
* From the definitions certtool-args.def
* and the template file options
*
diff --git a/src/certtool.c b/src/certtool.c
index c9506a1318..7ec33a96eb 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -2705,6 +2705,7 @@ void
pubkey_info (gnutls_x509_crt_t crt, common_info_st * cinfo)
{
gnutls_pubkey_t pubkey;
+ gnutls_privkey_t privkey;
int ret;
size_t size;
@@ -2723,14 +2724,25 @@ pubkey_info (gnutls_x509_crt_t crt, common_info_st * cinfo)
{
ret = gnutls_pubkey_import_x509 (pubkey, crt, 0);
if (ret < 0)
- {
- error (EXIT_FAILURE, 0, "pubkey_import_x509: %s",
- gnutls_strerror (ret));
- }
+ error (EXIT_FAILURE, 0, "pubkey_import_x509: %s",
+ gnutls_strerror (ret));
}
else
{
- pubkey = load_pubkey (1, cinfo);
+ privkey = load_private_key (0, cinfo);
+
+ if (privkey != NULL)
+ {
+ ret = gnutls_pubkey_import_privkey(pubkey, privkey, 0, 0);
+ if (ret < 0)
+ error (EXIT_FAILURE, 0, "pubkey_import_privkey: %s",
+ gnutls_strerror (ret));
+ }
+ else
+ {
+ gnutls_pubkey_deinit(pubkey);
+ pubkey = load_pubkey (1, cinfo);
+ }
}
if (outcert_format == GNUTLS_X509_FMT_DER)