summaryrefslogtreecommitdiff
path: root/src/certtool-common.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2015-10-16 13:16:36 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2015-10-16 15:58:33 +0200
commitf0033c9f2a89d14ff69fdc38f982c8f1a94a9570 (patch)
tree86048bc53f927c2a8ba2a45e620006608dbbfe55 /src/certtool-common.c
parent1c07fda247f1bb570cde745981b049f495678aac (diff)
downloadgnutls-f0033c9f2a89d14ff69fdc38f982c8f1a94a9570.tar.gz
tools: allow importing a pubkey from a certificate
Diffstat (limited to 'src/certtool-common.c')
-rw-r--r--src/certtool-common.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/certtool-common.c b/src/certtool-common.c
index 55c4c25c43..41b1655f19 100644
--- a/src/certtool-common.c
+++ b/src/certtool-common.c
@@ -638,22 +638,21 @@ gnutls_pubkey_t load_pubkey(int mand, common_info_st * info)
}
ret = gnutls_pubkey_import(key, &dat, info->incert_format);
-
- free(dat.data);
-
if (ret == GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR) {
- fprintf(stderr,
- "import error: could not find a valid PEM header; "
- "check if your key has the PUBLIC KEY header\n");
- exit(1);
- }
-
- if (ret < 0) {
+ ret = gnutls_pubkey_import_x509_raw(key, &dat, info->incert_format, 0);
+ if (ret < 0) {
+ fprintf(stderr,
+ "import error: could not find a valid PEM header; "
+ "check if your key has the PUBLIC KEY header\n");
+ exit(1);
+ }
+ } else if (ret < 0) {
fprintf(stderr, "importing --load-pubkey: %s: %s\n",
info->pubkey, gnutls_strerror(ret));
exit(1);
}
+ free(dat.data);
return key;
}