Encode keys in PKCS8 (private) and X509 (public) and test