Skip to content

Instantly share code, notes, and snippets.

@thomaslarsen
Last active February 20, 2024 20:12
Show Gist options
  • Save thomaslarsen/bc742bcd958896458d8006bdadf7d102 to your computer and use it in GitHub Desktop.
Save thomaslarsen/bc742bcd958896458d8006bdadf7d102 to your computer and use it in GitHub Desktop.
Convert PEM certificate to JSON format
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cert-name.pem
@steelysteel
Copy link

Helped me as well. Thanks @benaryorg

@ashishpatel1992
Copy link

Thanks @benaryorg . Really appreciate your solution.

@mr-molloy
Copy link

This is amazing. Much appreciated 😁

@ldnicolasmay
Copy link

If you need a more modern version of this you can use jq to do all sorts of magic with JSON. In any case you could run jq -sR . $any_file to convert the entire file to JSON.

Sorry, just happened to stumble on this and thought jq might help someone.

Yep... jq definitely comes in handy for this. Thanks @benaryorg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment