Hello everyone. I have a script that nicely formats the output of information about certificates on the router. It looks like this:
:for i from=0 to=([/certificate print count]-1) do={
:local cert [/certificate get $i];
:local name ($cert->"name");
:local cn ($cert->"common-name");
:local org ($cert->"organization");
:local country ($cert->"country");
:local state ($cert->"state");
:local city ($cert->"locality");
:local notBefore ($cert->"invalid-before");
:local notAfter ($cert->"invalid-after");
:local expiresAfter ($cert->"expires-after");
:local digest ($cert->"digest-algorithm");
:local keyType ($cert->"key-type");
:local keySize ($cert->"key-size");
:local usages ($cert->"key-usage");
:local skid ($cert->"skid");
:local fingerprint ($cert->"fingerprint");
:local stateStr "";
:if ($state != "") do={ :set stateStr (", " . $state) }
:local cityStr "";
:if ($city != "") do={ :set cityStr (", " . $city) }
:local skidStr "-";
:if ([:typeof $skid] = "str") do={ :set skidStr ([:pick $skid 0 10] . "...") }
:local fingerprintStr "-";
:if ([:typeof $fingerprint] = "str") do={ :set fingerprintStr ([:pick $fingerprint 0 8] . "...") }
:local issuerStr ($org . " (" . $country . $stateStr . $cityStr . ")");
:local usageStr [:pick $usages ([:find $usages ";Key Usage: "]+12) [:len $usages]];
:if ([:len $usageStr] = 0) do={ :set usageStr $usages }
:put (" 📄 Certificate #" . $i);
:put ("Name:\t\t" . $name);
:put ("Common Name (CN):\t" . $cn);
:put ("Issuer:\t\t" . $issuerStr);
:put ("Valid:\t\tfrom " . $notBefore . " to " . $notAfter);
:put ("Expires in:\t" . $expiresAfter);
:put ("Algorithm:\t" . $digest . ", " . $keyType . " " . $keySize . " bit");
:put ("Key Usage:\t" . $usages);
:put ("SKID:\t\t" . $skidStr);
:put ("Fingerprint:\t" . $fingerprintStr);
:put "";
}
But I want to rework it so that at the end I get a line with similar formatting. I try to glue it together, but I get nonsense. Then the same certificate is glued together. I have three of them. Then all three certificates are glued together 3-9 times. Can someone help?