Commit c9f21228db for strongswan.org

commit c9f21228dbf8add82c35240da2fbcbb866270f1b
Author: Tobias Brunner <tobias@strongswan.org>
Date:   Wed May 13 11:34:21 2026 +0200

    pki: Parse and print public keys directly to avoid dependency on pubkey plugin

diff --git a/configure.ac b/configure.ac
index c7c0ea5cfb..2247eb3287 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1477,7 +1477,7 @@ ADD_PLUGIN([x509],                 [s charon swanctl pki scripts attest nm cmd a
 ADD_PLUGIN([revocation],           [s charon pki nm cmd])
 ADD_PLUGIN([constraints],          [s charon pki nm cmd])
 ADD_PLUGIN([acert],                [s charon])
-ADD_PLUGIN([pubkey],               [s charon swanctl pki cmd aikgen])
+ADD_PLUGIN([pubkey],               [s charon swanctl cmd aikgen])
 ADD_PLUGIN([pkcs1],                [s charon swanctl pki scripts attest nm cmd aikgen fd fc])
 ADD_PLUGIN([pkcs7],                [s charon swanctl pki scripts nm cmd])
 ADD_PLUGIN([pkcs12],               [s charon swanctl pki scripts cmd])
diff --git a/src/pki/commands/print.c b/src/pki/commands/print.c
index bafadc830d..abbfd6e0b0 100644
--- a/src/pki/commands/print.c
+++ b/src/pki/commands/print.c
@@ -25,7 +25,7 @@
 /**
  * Print private key information
  */
-static void print_key(private_key_t *key)
+static void print_private_key(private_key_t *key)
 {
 	public_key_t *public;

@@ -76,8 +76,8 @@ static int print()
 				}
 				else if (streq(arg, "pub"))
 				{
-					type = CRED_CERTIFICATE;
-					subtype = CERT_TRUSTED_PUBKEY;
+					type = CRED_PUBLIC_KEY;
+					subtype = KEY_ANY;
 				}
 				else if (streq(arg, "priv"))
 				{
@@ -176,11 +176,18 @@ static int print()
 		printer->destroy(printer);
 		cert->destroy(cert);
 	}
-	if (type == CRED_PRIVATE_KEY)
+	else if (type == CRED_PUBLIC_KEY)
+	{
+		public_key_t *public = (public_key_t*)cred;
+
+		certificate_printer_print_pubkey(stdout, "  pubkey:", public, FALSE);
+		public->destroy(public);
+	}
+	else if (type == CRED_PRIVATE_KEY)
 	{
 		private_key_t *key = (private_key_t*)cred;

-		print_key(key);
+		print_private_key(key);
 		key->destroy(key);
 	}