How to upload a pfx format certificate to kong?
How to upload a PFX-format certificate to Kong
How do I upload a PFX-format certificate to Kong?
Kong’s Certificate entity only accepts PEM-format certificates and keys, so convert the .pfx file with openssl pkcs12 into separate key.pem and cert.pem files first (stripping any Bag Attributes / Key Attributes headers). Then upload both files to Kong as a Certificate entity, either through Kong Manager or the Admin API /certificates endpoint.
Overview
Steps
-
Convert a PFX file to separate certificate and private key PEM files:
openssl pkcs12 -in <pfx file> -nocerts -out key.pem -nodes openssl pkcs12 -in <pfx file> -nokeys -out cert.pem -
Remove
Bag Attributes,Key Attributesand any other attributes fromkey.pemandcert.pem.Make sure
key.pemis in the format below:-----BEGIN PRIVATE KEY----- xxxxxxxxxxxxxxxxxxxx -----END PRIVATE KEY-----Make sure
cert.pemis in the format below:-----BEGIN CERTIFICATE----- yyyyyyyyyyyyyyy -----END CERTIFICATE-----If you are using intermediate certificates,
cert.pemshould be in the format below instead:-----BEGIN CERTIFICATE----- <SERVER_CERTIFICATE> -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- <INTERMEDIATE_CERTIFICATE> -----END CERTIFICATE----- ... -
Upload
key.pemandcert.pemto Kong via Kong Manager or the Admin API:-
Upload using Kong Manager:
Access
http://<kong>:8002/<workspace>/certificates/create, copy the content fromcert.pemto the “Cert” input box, copy the content fromkey.pemto the “Key” input box, then click the “Create” button. -
Upload using the Admin API below:
curl -X POST http://<kong>:8001/<workspace>/certificates \ -F cert=@/path/to/cert.pem \ -F key=@/path/to/key.pem
-
Check more details in the Certificate entity - set up a certificate documentation.