Author: Paul Bastide

  • Formatting JSON with VIM

    I am working on an analytics project where we generate very complicated medical analysis and put it in a hierarchical data model.

    json

    { "test" : { "test1" : "val1" } }

    Open the JSON in vim and use python -m json.tool

    :%!python -m json.tool

    Results

    json

    {
        "test": {
            "test1": "val1"
        }
    }

    Note: jq (jq is another option, but… not always available on every system, python tends to work everywhere).

    References

  • Extract the Certs (All of Them)

    Quick way to extract the main cert, and the intermediate CA and ROOT ca from a host.

    shell

    echo "" | openssl s_client -showcerts -prexit -connect HOSTNAME:443 2> /dev/null | sed -n -e '/BEGIN CERTIFICATE/,/END CERTIFICATE/ p'

    One sees a PEM as output (just capture into a file one can use)