User Tools

Site Tools


paloaltonetworks:api:certificates

This is an old revision of the document!


PAN-OS API Certificates

Prefix all commands with

https://10.1.1.1/api/?key=API_KEY

Certificates

RSA Algorithm Options

  • 512
  • 1024
  • 2048
  • 3072
  • 4096

ECDSA Algorithm Options

  • 256
  • 384

Digest Options

  • md5
  • sha1
  • sha256
  • sha384
  • sha512

Generate Certificates

Generate Certificate Signing Request (Not CA

&type=op&cmd=<request><certificate><generate><digest>sha256</digest><algorithm><RSA><rsa-nbits>2048</rsa-nbits></RSA></algorithm><days-till-expiry>270</days-till-expiry><signed-by>external</signed-by><hostname><member>FW-01.example.local</member><member>FW-01</member></hostname><ip><member>1.1.1.1</member></ip><certificate-name>CERT_MGT_FW-01</certificate-name><name>FW-01.example.local</name></generate></certificate></request>

Generate Certificate Signing Request (CA

&type=op&cmd=<request><certificate><generate><ca>yes</ca><digest>sha256</digest><algorithm><RSA><rsa-nbits>2048</rsa-nbits></RSA></algorithm><days-till-expiry>270</days-till-expiry><signed-by>external</signed-by><hostname><member>FW-01.example.local</member><member>FW-01</member></hostname><ip><member>1.1.1.1</member></ip><certificate-name>CERT_MGT_FW-CA</certificate-name><name>FW-01.example.local</name></generate></certificate></request>

Generate Certificate (Not CA) Using CA on Firewall

&type=op&cmd=<request><certificate><generate><digest>sha256</digest><algorithm><RSA><rsa-nbits>2048</rsa-nbits></RSA></algorithm><days-till-expiry>270</days-till-expiry><signed-by>GPCERT</signed-by><hostname><member>FW-01.example.local</member><member>FW-01</member></hostname><ip><member>1.1.1.1</member></ip><certificate-name>SelfSignedNotCA</certificate-name><name>FW-01.example.local</name></generate></certificate></request>

Generate Certificate (Subordinate CA) Using CA on Firewall

&type=op&cmd=<request><certificate><generate><ca>yes</ca><digest>sha256</digest><algorithm><RSA><rsa-nbits>2048</rsa-nbits></RSA></algorithm><days-till-expiry>270</days-till-expiry><signed-by>GPCERT</signed-by><hostname><member>FW-01.example.local</member><member>FW-01</member></hostname><ip><member>1.1.1.1</member></ip><certificate-name>SubCA</certificate-name><name>FW-01.example.local</name></generate></certificate></request>

Generate Certificate (CA) Self Signed

&type=op&cmd=<request><certificate><generate><ca>yes</ca><digest>sha256</digest><algorithm><RSA><rsa-nbits>2048</rsa-nbits></RSA></algorithm><days-till-expiry>270</days-till-expiry><hostname><member>FW-01.example.local</member><member>FW-01</member></hostname><ip><member>1.1.1.1</member></ip><certificate-name>SelfSignedCA</certificate-name><name>FW-01.example.local</name></generate></certificate></request>

Show Certificate Details

&type=op&cmd=<request><certificate><show><certificate-name>CERTIFICATE_NAME</certificate-name></show></certificate></request>

Set Trust and Untrust Certificates

Shared

In this example, the certificates are DECRYPT and DECRYPECDSA. Delete the ECDSA or RSA elements as required.

&type=config&action=set&xpath=/config/shared&element=<ssl-decrypt><forward-trust-certificate><rsa>DECRYPT</rsa><ecdsa>DECRYPTECDSA</ecdsa></forward-trust-certificate><forward-untrust-certificate><rsa>DECRYPT</rsa><ecdsa>DECRYPTECDSA</ecdsa></forward-untrust-certificate><ssl-decrypt>

VSYS

In this example, the certificates are DECRYPT and DECRYPECDSA. Delete the ECDSA or RSA elements as required.

&type=config&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']&element=<ssl-decrypt><forward-trust-certificate><rsa>DECRYPT</rsa><ecdsa>DECRYPTECDSA</ecdsa></forward-trust-certificate><forward-untrust-certificate><rsa>DECRYPT</rsa><ecdsa>DECRYPTECDSA</ecdsa></forward-untrust-certificate><ssl-decrypt>

Export Certificates

For Panorama, currently I import/export all certificates to Panorama (mgmt) itself and then load partial to copy the signed certificates into specific templates. The 'import' and 'export' commands do not have a documented way of interfacing with Templates directly.

Export Certificate Signing Request

&type=export&category=certificate&certificate-name=CERT_MGT_FW-01&format=pkcs10&include-key=no

You can add the following to cURL to send to a file

 > CSR_FILE.csr

Export Certificate (Public Key Only

&type=export&category=certificate&certificate-name=CERTIFICATE_NAME&format=pem&include-key=no

You can add the following to cURL to send to a file

 > CERTIFICATE_PUB_ONLY.crt

Export Certificate (Public and Private Key

&type=export&category=certificate&certificate-name=CERTIFICATE_NAME&format=pem&include-key=yes&passphrase=the_passphrase

You can add the following to cURL to send to a file

 > CERTIFICATE_WITH_KEY.crt

Import Certificates

Remember to put the following cURL command before the HTTPS request

curl --insecure  --form file=@cert.pem

Import Certificate (Signed Public Certificate Base64

&type=import&category=certificate&format=pem&certificate-name=ImportedCert

Import Certificate (Password Protected Public Key Only

&type=import&category=certificate&format=pem&passphrase=password&certificate-name=ImportedCert

Import Certificate (Password Protected Public and Private Key

&type=import&category=keypair&format=pem&passphrase=password&certificate-name=ImportedCert

Import Private Key (Where Public Key Already Imported

&type=import&category=private-key&format=pem&passphrase=password&certificate-name=ImportedCert

Panorama

Load Panorama Certificate into Template (VSYS Specific

&type=op&cmd=<load><config><partial><from>running-config.xml</from><from-xpath>/config/panorama/certificate/entry[@name='CERTIFICATE_NAME']</from-xpath><to-xpath>/config/devices/entry[@name='localhost.localdomain']/template/entry[@name='TEMPLATE_NAME']/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/certificate/entry[@name='CERTIFICATE_NAME']</to-xpath><mode>merge</mode></partial></config></load>

Load Panorama Certificate into Template (Shared

&type=op&cmd=<load><config><partial><from>running-config.xml</from><from-xpath>/config/panorama/certificate/entry[@name='CERTIFICATE_NAME']</from-xpath><to-xpath>/config/devices/entry[@name='localhost.localdomain']/template/entry[@name='TEMPLATE_NAME']/config/shared/certificate/entry[@name='CERTIFICATE_NAME']</to-xpath><mode>merge</mode></partial></config></load>

HA Certificates

Import HA Key

curl --insecure --form file=@haKey.txt "&type=import&category=high-availability-key"
paloaltonetworks/api/certificates.1590236375.txt.gz · Last modified: (external edit)