Skip to main content

This snippet will convert a PEM based certificate of key to JSON format. This is useful when having to embed a certificate in a JSON object.

#!/usr/bin/env bash

##
# Convert a PEM based file to JSON
#
# This snippet will convert a PEM based certificate of key to JSON format.
# This is useful when having to embed a certificate in a JSON object.
#
# It will simply add `\n` in the required places.
#
# The snipped was copied from here:
# https://docs.vmware.com/en/Unified-Access-Gateway/2.9/com.vmware.access-point-29-deploy-config/GUID-870AF51F-AB37-4D6C-B9F5-4BFEB18F11E9.html
##

awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cert-name.pem