aboutsummaryrefslogtreecommitdiffstats
path: root/src/pki/commands/pub.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-08-15 12:43:30 +0200
committerTobias Brunner <tobias@strongswan.org>2013-09-13 15:23:49 +0200
commit90afd2c9290b3b0bd605444d58c271a15b6df2b3 (patch)
tree08c2fef63e12b2491a0df2ac7f5dd02d80234255 /src/pki/commands/pub.c
parent21626bdf77957d60631fe939fc00f77c4a429f75 (diff)
downloadstrongswan-90afd2c9290b3b0bd605444d58c271a15b6df2b3.tar.bz2
strongswan-90afd2c9290b3b0bd605444d58c271a15b6df2b3.tar.xz
pki: --pub also accepts public keys (i.e. to convert them to a different format)
Diffstat (limited to 'src/pki/commands/pub.c')
-rw-r--r--src/pki/commands/pub.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/pki/commands/pub.c b/src/pki/commands/pub.c
index d85ee9ff3..537af5159 100644
--- a/src/pki/commands/pub.c
+++ b/src/pki/commands/pub.c
@@ -51,6 +51,11 @@ static int pub()
type = CRED_PRIVATE_KEY;
subtype = KEY_ECDSA;
}
+ else if (streq(arg, "pub"))
+ {
+ type = CRED_PUBLIC_KEY;
+ subtype = KEY_ANY;
+ }
else if (streq(arg, "pkcs10"))
{
type = CRED_CERTIFICATE;
@@ -116,6 +121,15 @@ static int pub()
public = private->get_public_key(private);
private->destroy(private);
}
+ else if (type == CRED_PUBLIC_KEY)
+ {
+ public = cred;
+ if (!public)
+ {
+ fprintf(stderr, "parsing public key failed\n");
+ return 1;
+ }
+ }
else
{
cert = cred;
@@ -157,7 +171,7 @@ static void __attribute__ ((constructor))reg()
command_register((command_t) {
pub, 'p', "pub",
"extract the public key from a private key/certificate",
- {"[--in file|--keyid hex] [--type rsa|ecdsa|pkcs10|x509]",
+ {"[--in file|--keyid hex] [--type rsa|ecdsa|pub|pkcs10|x509]",
"[--outform der|pem|dnskey|sshkey]"},
{
{"help", 'h', 0, "show usage information"},