#!/usr/bin/perl

use strict;
use IO::File;

my $cert = new IO::File(">./cert.pem") || die "Can't open cert.pem: $!\n";
my $key = new IO::File(">./key.pem") || die "Can't open key.pem: $!\n";

while (<>) {
    (/-----BEGIN.*PRIVATE KEY/ .. /-----END.*PRIVATE KEY/) && do {
	print $key $_;
    };
    (/-----BEGIN CERTIFICATE/ .. /-----END CERTIFICATE/) && do {
	print $cert $_;
    };
}
$key->close();
$cert->close();
