I am trying to generate a Certificate Signing Request using php. My code file (generateReq.php) is as follows:
- Code: Select all
<?php
$dn = array(
"countryName" => "UK",
"stateOrProvinceName" => "Somerset",
"localityName" => "Glastonbury",
"organizationName" => "The Brain Room Limited",
"organizationalUnitName" => "PHP Documentation Team",
"commonName" => "Wez Furlong",
"emailAddress" => "wez@example.com"
);
// Generate a new private (and public) key pair
$configargs = array('config' => 'C:\\PHP\\extras\\openssl\\openssl.cnf');
$pkey = openssl_pkey_new($configargs);
// Show any errors that occurred here
while (($e = openssl_error_string()) !== false) {
echo $e . "\n";
}
?>
I have php_openssl.dll in C:\PHP\ext directory and libeay32.dll and ssleay32.dll in C:\Windows\system32 directory. My openssl.cnf file is at location C:\PHP\extras\openssl\openssl.cnf
The content of openssl.cnf file are as follows:
- Code: Select all
#######################################################################
# File name: openssl.cnf
# Created By: The Uniform Server Development Team
# Edited Last By: Mike Gleaves (ric)
# V 1.0 7-1-2009
# Uses OpenSSL 0.9.8i
########################################################################
#
# OpenSSL configuration file.
#
# Establish working directory.
dir = ./
[ req ]
default_bits = 1024
default_md = md5
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
x509_extensions = v3_ca
string_mask = nombstr
[ req_distinguished_name ]
countryName = PK
countryName_min = 2
countryName_max = 2
stateOrProvinceName = Punjab
localityName = ISB
0.organizationName = NCP
organizationalUnitName = ASC
commonName = ADEEL
commonName_max = 64
emailAddress = adeel@ncp.edu.pk
emailAddress_max = 64
[ ssl_server ]
basicConstraints = CA:FALSE
nsCertType = server
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth, nsSGC, msSGC
nsComment = "OpenSSL Certificate for SSL Web Server"
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
[ v3_ca ]
basicConstraints = critical, CA:true, pathlen:0
nsCertType = sslCA
keyUsage = cRLSign, keyCertSign
extendedKeyUsage = serverAuth, clientAuth
nsComment = "OpenSSL CA Certificate"
when I run generateReq.php file in the browser, I got following error
error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value error:0E06D06C:configuration file routines:NCONF_get_string:no value
I have spent 2 days to find out the reason about this error type but in vain. Would anyone please help me.
Thanks.

