Refactor Machine Cert method

Prior to this commit we did hacky shell code to get this value exported
to disk. This commit uses python to do most of the heavy lifting