Merge pull request #1984 from AndreLouisCaron/cert-encoding

Adds certificate encoding to PEM and DER.