<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: VPN User Certificates in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146830#M6752</link>
    <description>&lt;P&gt;Ah!!&amp;nbsp; Just for a laugh I tried exactly the same command from a normal SSH session instead and it works!&amp;nbsp; I'm not sure what the difference is, but happy days&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-04-22 084828.png" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/16159iF229F7412BF78668/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-04-22 084828.png" alt="Screenshot 2022-04-22 084828.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Apr 2022 07:50:25 GMT</pubDate>
    <dc:creator>biskit</dc:creator>
    <dc:date>2022-04-22T07:50:25Z</dc:date>
    <item>
      <title>VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146567#M6742</link>
      <description>&lt;P&gt;Is there a way via API to generate a new user "Registration Key for certificate enrollment" for a given user?&lt;/P&gt;&lt;P&gt;The equivalent of this in SmartConsole?&lt;/P&gt;&lt;P&gt;I have a looong list of users to issue certificate registration keys for and to save a lot of time I want to do this via API and get all the usernames/codes outputted to a file?&amp;nbsp; &amp;nbsp;(The user objects already exist - I just need the API syntax to generate a new registration code and capture that code somehow)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-04-20 103552.png" style="width: 614px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/16093i933A9DA334E78979/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-04-20 103552.png" alt="Screenshot 2022-04-20 103552.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 09:48:01 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146567#M6742</guid>
      <dc:creator>biskit</dc:creator>
      <dc:date>2022-04-20T09:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146604#M6744</link>
      <description>&lt;P&gt;Hi Matt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will the batch creation tool in the UI work for this? If not - a little bit of scripting around something like this should work (and you can replace the root login with something more suitable in your environment of course).&lt;/P&gt;
&lt;P&gt;mgmt_cli -r true set user name tempuser certificates.add.1.registration-key.comment "new reg key"&lt;/P&gt;
&lt;P&gt;mgmt_cli -r true show user name tempuser show-certificates true --format json | jq '.certificates[0]."registration-key"'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The jq part will return the first registration key present for the user, so you might want to sort them on date created to get the most recent, or filter it based on the comment you provided.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 14:11:04 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146604#M6744</guid>
      <dc:creator>StuartGreen</dc:creator>
      <dc:date>2022-04-20T14:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146745#M6749</link>
      <description>&lt;P&gt;Thanks Stuart, that's almost awesome!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&amp;nbsp; I just couldn't find the syntax anywhere for generating reg keys so thanks for your reply.&lt;/P&gt;&lt;P&gt;The first command to generate a new registration key works fine.&lt;/P&gt;&lt;P&gt;The second command gives me an error...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-04-21 180330.png" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/16115iA2C59BE3253CB819/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-04-21 180330.png" alt="Screenshot 2022-04-21 180330.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I run:&lt;/P&gt;&lt;P&gt;&amp;gt; show user name mattdunn show-certificates true&lt;/P&gt;&lt;P&gt;...then it returns all of my user info, including a line showing the cert registration key, so it seems there's something funky not quite right with the --format switch?&amp;nbsp; Do you have any ideas?&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 17:08:31 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146745#M6749</guid>
      <dc:creator>biskit</dc:creator>
      <dc:date>2022-04-21T17:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146756#M6750</link>
      <description>&lt;P&gt;Hmm, that's odd. Works ok for me on R81.10 management:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-04-21 at 20.06.48.png" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/16119iA5100FEBD656694E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-04-21 at 20.06.48.png" alt="Screenshot 2022-04-21 at 20.06.48.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The &amp;gt; at the start of your second line makes it look like there are some unbalanced quotes in there. The only quotes should be those around the value after jq. Single quotes around the whole string and double quotes around registration-key.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try it without the | jq bit and you should just get the JSON format output from the mgmt_cli command.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 19:15:41 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146756#M6750</guid>
      <dc:creator>StuartGreen</dc:creator>
      <dc:date>2022-04-21T19:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146826#M6751</link>
      <description>&lt;P&gt;I'm on R81.10 too, using the Command Line accessible from SmartConsole in this instance.&lt;/P&gt;&lt;P&gt;I'm running:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;show user name mattdunn show-certificates true --format json | jq '.certificates[0]."registration-key"'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copy/pasted from your original post so I know I have the correct quote symbols...&amp;nbsp; With or without the &lt;STRONG&gt;| jq&lt;/STRONG&gt; part I still get the error about missing parameters.&amp;nbsp; Odd.&amp;nbsp; I'll keep having a play and see what I come up with...&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 07:43:19 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146826#M6751</guid>
      <dc:creator>biskit</dc:creator>
      <dc:date>2022-04-22T07:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146830#M6752</link>
      <description>&lt;P&gt;Ah!!&amp;nbsp; Just for a laugh I tried exactly the same command from a normal SSH session instead and it works!&amp;nbsp; I'm not sure what the difference is, but happy days&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-04-22 084828.png" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/16159iF229F7412BF78668/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-04-22 084828.png" alt="Screenshot 2022-04-22 084828.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 07:50:25 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146830#M6752</guid>
      <dc:creator>biskit</dc:creator>
      <dc:date>2022-04-22T07:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146838#M6753</link>
      <description>&lt;P&gt;awesome news &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CLI in Smart Console is fine for pure API commands, but because the JQ tool is an external tool (eg, not part of mgmt_cli) you'll need to call that from an expert mode session. I'd guess that the Smart Console terminal tried to interpret the pipe and everything after it as API arguments.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 10:33:43 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146838#M6753</guid>
      <dc:creator>StuartGreen</dc:creator>
      <dc:date>2022-04-22T10:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146839#M6754</link>
      <description>&lt;P&gt;I've since hit another snag which I'm trying to work around...&amp;nbsp; I've found if the user has already got a cert issued, or has had one in the past, a record of those active/revoked certs is still in the user details (if you run the show command without the json filter on the end), so in that case, even though somewhere in the user info output there is a new Registration Key code, your command just returns &lt;STRONG&gt;"null"&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;So it seems to only work for the very first time you issue a cert.&amp;nbsp; If you want to revoke and issue another code the "show" command doesn't work.&amp;nbsp; I presume there's a way to essentially do the equivalent of a &lt;STRONG&gt;| grep registration-key&lt;/STRONG&gt; to show the code?&lt;/P&gt;&lt;P&gt;I'm useless at API/json commands but I'll have a Google and see what I can find...&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 10:44:59 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146839#M6754</guid>
      <dc:creator>biskit</dc:creator>
      <dc:date>2022-04-22T10:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146841#M6755</link>
      <description>&lt;P&gt;ahh yes you'll need to apply some filtering either in your script or with JQ. JQ can be a really useful tool, but sometimes it's not very friendly. If as part of your script for creating the registration key you create a random string for the comment (or at least something unique that can identity the new reg key) you can do something like this...&lt;/P&gt;
&lt;P&gt;create the key with the unique comment / token:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;mgmt_cli -r true set user name tempuser certificates.add.1.registration-key.comment "tempuserNEWKEY22"&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;Then to get the registration key which matches the unique comment:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;mgmt_cli -r true show user name tempuser show-certificates true --format json | jq '.certificates[] | select(.comments == "tempuserNEWKEY22") | ."registration-key"'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That will return the reg key that matches the comment you provide.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 11:33:17 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146841#M6755</guid>
      <dc:creator>StuartGreen</dc:creator>
      <dc:date>2022-04-22T11:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: VPN User Certificates</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146847#M6756</link>
      <description>&lt;P&gt;Awesome, thanks Stuart!&amp;nbsp; I'll do some more testing but that appears to work&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 13:06:29 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/VPN-User-Certificates/m-p/146847#M6756</guid>
      <dc:creator>biskit</dc:creator>
      <dc:date>2022-04-22T13:06:29Z</dc:date>
    </item>
  </channel>
</rss>

