<?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 XML API powershell, importing  public wildcard pkcs12 certificates in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-powershell-importing-public-wildcard-pkcs12-certificates/m-p/519561#M3225</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I'm trying to automate importing public wildcard pkcs12 certificates with passphrase into Palo Altos with XML API and powershell.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Importing the cert in the&amp;nbsp; web gui works fine, I give it a name, browse to the .pfx file, select format&amp;nbsp;pkcs12, and enter and confirm the passphrase. Great! And then I can create other profiles and reference that cert.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;However, I need to automate this import.&lt;/P&gt;&lt;P&gt;Following the instructions on&amp;nbsp;&lt;A href="https://docs.paloaltonetworks.com/pan-os/10-1/pan-os-panorama-api/pan-os-xml-api-use-cases/manage-certificates-api" target="_blank"&gt;https://docs.paloaltonetworks.com/pan-os/10-1/pan-os-panorama-api/pan-os-xml-api-use-cases/manage-certificates-api&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's what I do in powershell :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;$certFile = "wildcard.pfx"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$passPhrase = "xxxxx"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$certName="WILDCARD-CERT"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;$WANIP = "65.65.65.6&lt;/P&gt;&lt;P&gt;$apikey = "yyyyyyy"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;$apiurl = "https://" + $wanip + "//api/?key=" + $apiKey + "&amp;amp;type=import&amp;amp;category=keypair&amp;amp;certificate-name=$certName&amp;amp;format=pkcs12&amp;amp;passphrase=$passPhrase"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;within powershell I call&amp;nbsp;&lt;SPAN&gt;C:\Windows\System32\curl.exe because "curl" on powershell is just an alias for Invoke-webrequest (which by the way is my preferred way of call the PanOS API)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Windows\System32\curl.exe -F "file=@$certFile" $apiurl&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the result is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued by an authority that is not trusted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;More details here:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://curl.se/docs/sslcerts.html" target="_blank" rel="noopener"&gt;https://curl.se/docs/sslcerts.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;curl failed to verify the legitimacy of the server and therefore could not&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;establish a secure connection to it. To learn more about this situation and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;how to fix it, please visit the web page mentioned above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I use -k for insecure,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Windows\System32\curl.exe -k -F "file=@$certFile" $apiurl&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the result is :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;response status="error"&amp;gt;&amp;lt;msg&amp;gt;&amp;lt;line&amp;gt;Import of certificate and private-key "WILDCARD-CERT" failed. Failed to extract certificate&amp;lt;/line&amp;gt;&amp;lt;/msg&amp;gt;&amp;lt;/response&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, as I said, it works just fine if I import it in the Palo Alto web gui.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any help would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Oct 2022 16:42:16 GMT</pubDate>
    <dc:creator>RogerMccarrick</dc:creator>
    <dc:date>2022-10-28T16:42:16Z</dc:date>
    <item>
      <title>XML API powershell, importing  public wildcard pkcs12 certificates</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-powershell-importing-public-wildcard-pkcs12-certificates/m-p/519561#M3225</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I'm trying to automate importing public wildcard pkcs12 certificates with passphrase into Palo Altos with XML API and powershell.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Importing the cert in the&amp;nbsp; web gui works fine, I give it a name, browse to the .pfx file, select format&amp;nbsp;pkcs12, and enter and confirm the passphrase. Great! And then I can create other profiles and reference that cert.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;However, I need to automate this import.&lt;/P&gt;&lt;P&gt;Following the instructions on&amp;nbsp;&lt;A href="https://docs.paloaltonetworks.com/pan-os/10-1/pan-os-panorama-api/pan-os-xml-api-use-cases/manage-certificates-api" target="_blank"&gt;https://docs.paloaltonetworks.com/pan-os/10-1/pan-os-panorama-api/pan-os-xml-api-use-cases/manage-certificates-api&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's what I do in powershell :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;$certFile = "wildcard.pfx"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$passPhrase = "xxxxx"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$certName="WILDCARD-CERT"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;$WANIP = "65.65.65.6&lt;/P&gt;&lt;P&gt;$apikey = "yyyyyyy"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;$apiurl = "https://" + $wanip + "//api/?key=" + $apiKey + "&amp;amp;type=import&amp;amp;category=keypair&amp;amp;certificate-name=$certName&amp;amp;format=pkcs12&amp;amp;passphrase=$passPhrase"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;within powershell I call&amp;nbsp;&lt;SPAN&gt;C:\Windows\System32\curl.exe because "curl" on powershell is just an alias for Invoke-webrequest (which by the way is my preferred way of call the PanOS API)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Windows\System32\curl.exe -F "file=@$certFile" $apiurl&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the result is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;curl: (60) schannel: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued by an authority that is not trusted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;More details here:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://curl.se/docs/sslcerts.html" target="_blank" rel="noopener"&gt;https://curl.se/docs/sslcerts.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;curl failed to verify the legitimacy of the server and therefore could not&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;establish a secure connection to it. To learn more about this situation and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;how to fix it, please visit the web page mentioned above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I use -k for insecure,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Windows\System32\curl.exe -k -F "file=@$certFile" $apiurl&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the result is :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;response status="error"&amp;gt;&amp;lt;msg&amp;gt;&amp;lt;line&amp;gt;Import of certificate and private-key "WILDCARD-CERT" failed. Failed to extract certificate&amp;lt;/line&amp;gt;&amp;lt;/msg&amp;gt;&amp;lt;/response&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, as I said, it works just fine if I import it in the Palo Alto web gui.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;any help would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 16:42:16 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-powershell-importing-public-wildcard-pkcs12-certificates/m-p/519561#M3225</guid>
      <dc:creator>RogerMccarrick</dc:creator>
      <dc:date>2022-10-28T16:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: XML API powershell, importing  public wildcard pkcs12 certificates</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-powershell-importing-public-wildcard-pkcs12-certificates/m-p/519612#M3226</link>
      <description>&lt;P&gt;I think I have a resolution.&lt;/P&gt;&lt;P&gt;I exported the cert from its original place, but this time as a BASE64 .pem file, exporting private key and using a passphrase.&lt;/P&gt;&lt;P&gt;Using the -k (insecure) with curl, the import was actually successful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$certFile = "wildcard.pem"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$apiurl = "https://" + $wanip + "//api/?key=" + $apiKey + "&amp;amp;type=import&amp;amp;category=keypair&amp;amp;certificate-name=$certName&amp;amp;format=&lt;STRONG&gt;pem&lt;/STRONG&gt;&amp;amp;passphrase=$passPhrase"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;C:\Windows\System32\curl.exe -k -F "file=@$CertFile" $apiurl&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;lt;response status="success"&amp;gt;&amp;lt;result&amp;gt;Successfully imported WILDCARD-CERT into candidate configuration&amp;lt;/result&amp;gt;&amp;lt;/response&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not know why the pkcs12 format doesn’t work. &amp;nbsp;It seems that I can ask my end users to supply the cert in &lt;STRONG&gt;.pem&lt;/STRONG&gt; format. This should work just fine.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Oct 2022 18:46:48 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-powershell-importing-public-wildcard-pkcs12-certificates/m-p/519612#M3226</guid>
      <dc:creator>RogerMccarrick</dc:creator>
      <dc:date>2022-10-29T18:46:48Z</dc:date>
    </item>
  </channel>
</rss>

