Login   Register  
PHP Classes
elePHPant
Icontem

OpenSSL with PHP

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Crypt_OpenSSL  >  All threads  >  OpenSSL with PHP  >  (Un) Subscribe thread alerts  
Subject:OpenSSL with PHP
Summary:Signature Algorithm change from md5WithRSA to sha1WithRSA
Messages:1
Author:kerbarous
Date:2011-09-05 07:50:42
 

  1. OpenSSL with PHP   Reply  
Picture of kerbarous
kerbarous
2011-09-05 07:50:42
I want to make the Certificat using PHP's OpenSSL functions, yesterday I've managed to make but the Signature Algorithm md5WithRSAEncryption wear, I want it in the Signature Algorithm md5WithRSAEncryption be sha1WithRSAEncryption, can roughly ngak huh?.
Please help me...
This sample script that I've created :
<?php
$dn = array(
"countryName" => "ID",
"stateOrProvinceName" => "propinsi",
"localityName" => "kota",
"organizationName" => "oraganisasi",
"organizationalUnitName" => "unit",
"commonName" => "nama",
"emailAddress" => "jhon@yahoo.com"
);

$params = array(
'digest_alg' => 'sha1',
'x509_extensions' => 'v3_ca',
'req_extensions' => 'v3_req',
'private_key_bits' => 1024,
'private_key_type'=>OPENSSL_KEYTYPE_RSA,
'encrypt_key'=>true
);

$private_key = openssl_pkey_new($params);
openssl_pkey_export($private_key,$private_key_stri ng,"password");

//generate certificate (to get a public key from it)
$csr = openssl_csr_new($dn, $private_key);
$cert = openssl_csr_sign($csr, null, $private_key, 365);

// get the private key
openssl_pkey_export_to_file($private_key,"htdocs/belajar/Myencryption/server.key","password",$dn);

//get the public key from the certificate
openssl_x509_export($cert, $public_key_string);
openssl_x509_export_to_file($public_key_string,"htdocs/belajar/Myencryption/server.crt",false);

?>