List Info

Thread: note 74187 added to ref.openssl




note 74187 added to ref.openssl
user name
2007-03-29 01:57:22
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;
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 71.97.212.146
----
Manual Page -- http://w
ww.php.net/manual/en/ref.openssl.php
Edit        -- https://master
.php.net/note/edit/74187
Del: integrated  -- h
ttps://master.php.net/note/delete/74187/integrated
Del: useless     -- http
s://master.php.net/note/delete/74187/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/74187/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/74187/spam
Del: non-english -- 
https://master.php.net/note/delete/74187/non-english
Del: in docs     -- http
s://master.php.net/note/delete/74187/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74187
Reject      -- https://mast
er.php.net/note/reject/74187
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


note 74187 deleted from ref.openssl by bobby
user name
2007-03-29 09:30:57
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;
}
?>

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )