note 74187 deleted from ref.openssl by bobby

From: Date: Thu, 29 Mar 2007 14:30:57 +0000
Subject: note 74187 deleted from ref.openssl by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-124917@lists.php.net to get a copy of this message
Note Submitter: ---- Currently, all OpenSSL Functions defined in PHP only utilize the PEM format. Use the following code to convert from DER to PEM and PEM to DER. <?php $pem_data = file_get_contents($cert_path.$pem_file); $pem2der = pem2der($pem_data); $der_data = file_get_contents($cert_path.$der_file); $der2pem = der2pem($der_data); function pem2der($pem_data) { $begin = "CERTIFICATE-----"; $end = "-----END"; $pem_data = substr($pem_data, strpos($pem_data, $begin)+strlen($begin)); $pem_data = substr($pem_data, 0, strpos($pem_data, $end)); $der = base64_decode($pem_data); return $der; } function der2pem($der_data) { $pem = chunk_split(base64_encode($der_data), 64, "\n"); $pem = "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n"; return $pem; } ?>

« previous php.notes (#124917) next »