Max Max - 20 days ago 8
Perl Question

Various PEM to DER in perl

i have application with client-server architecture.

client (C program):


  1. generate various DER encoded data

  2. convert DER to PEM (using openssl's PEM_write_bio) with various PEM header

  3. send PEM to server



server (Perl script):


  1. receive PEM data

  2. convert PEM to DER

  3. ....



My question is how to convert various PEM data to DER/BER (binary data) in perl?

Answer

You can strip off the PEM tags yourself, and do a decode of the Base64 block inside using MIME::Base64.

Should be as simple as

$derBlob = decode_base64($base64Blob);