private function toDer()
    {
        $pattern = '/.*-----BEGIN CERTIFICATE-----(.*)-----END CERTIFICATE-----.*/msU';
        $replacement = '${1}';

        $plainPemData = preg_replace($pattern, $replacement, $this->pemCert);
        if (null === $plainPemData) {
            throw new RuntimeException('unable to extract the encoded DER data from the certificate');
        }

        // create one long string of the certificate which turns it into an
        // encoded DER cert
        $search = array(' ', "\t", "\n", "\r", "\0" , "\x0B");
        $encodedDerCert = str_replace($search, '', $plainPemData);

        return base64_decode($encodedDerCert);
    }