Yes, I think we are doing it right:

> You'll want to parse what's between the BEGIN-END blocks.

> Inside, you'll find a Base64 encoded entity that you need to Base64 decode into bytes. These bytes represent a DER encoded certificate/key/etc.

pem/emcodings does everything  up to and including the base64 decode.

http://stackoverflow.com/a/5355734/15677