keySize = $keySize; $this->digestAlgorithm = $digestAlgorithm; $this->countryCode = $countryCode; $this->state = $state; $this->locality = $locality; $this->organization = $organization; $this->organizationalUnit = $organizationalUnit; $this->commonName = $commonName; $this->emailAddress = $emailAddress; } } function createCSR($csrFile,$keyFile,$csrReqInfo) { error_log("Generating Primary Key file."); exec("/usr/bin/openssl genrsa -out $keyFile $csrReqInfo->keySize", $results, $rc); $error=0; if ($rc == 0 ) { error_log("Primary key file, ".$keyFile.", generated."); error_log("Generating certificate signing request."); if ($csrReqInfo->emailAddress == "") { $subj="/C=".$csrReqInfo->countryCode."/ST=".$csrReqInfo->state."/L=".$csrReqInfo->locality."/O=".$csrReqInfo->organization."/OU=".$csrReqInfo->organizationalUnit."/CN=".$csrReqInfo->commonName; } else { $subj="/C=".$csrReqInfo->countryCode."/ST=".$csrReqInfo->state."/L=".$csrReqInfo->locality."/O=".$csrReqInfo->organization."/OU=".$csrReqInfo->organizationalUnit."/CN=".$csrReqInfo->commonName."/emailAddress=".$csrReqInfo->emailAddress; } error_log("Subject data: ".$subj); $cmd="/usr/bin/openssl req -new -".$csrReqInfo->digestAlgorithm." -key ".$keyFile." -out ".$csrFile." -subj \"".$subj."\""; error_log("cmd: ".$cmd); exec($cmd,$results,$rc); if ($rc == 0) { error_log("Generated certificate signing request."); $cmd="sudo /bin/mv ".$keyFile." /home/embedded/library/HTTPService/certs/userPrimaryKey.pem"; error_log("cmd: ".$cmd); exec($cmd,$results,$rc); if ($rc == 0) { error_log("Primary key file has been moved to /home/embedded/library/HTTPService/certs."); } else { error_log("Primary key file move to /home/embedded/library/HTTPService/certs failed."); } } else { error_log("Generation of certificate signing request failed."); error_log("Results: ".print_r($results,true)); } } else { error_log("Primary key file, ".$keyFile.", generation failed."); error_log("Results: ".print_r($results,true)); } return $error; } if ($_SERVER[REQUEST_METHOD] == "POST") { error_log($_FILES." _FILES = ". print_r($_FILES, true) ); error_log($_SERVER['REQUEST_URI']." POST = ". print_r($_POST, true) ); $operationInProgress = true; $status = new ReturnStatus(); $status->context = "createCSR"; $csrInfo=new csrInformation($_POST['keyLength'],$_POST['digestAlg'],$_POST['countryCode'],$_POST['stateprovince'],$_POST['locality'],$_POST['organization'], $_POST['organizationalUnit'],$_POST['commonName'],$_POST['emailAddress']); error_log("csrInfo: ".print_r($csrInfo,true)); $iRet=createCSR($csrFile,$keyFile,$csrInfo); if( $iRet == 0 ) { error_log("Certificate signing request created."); } else { error_log("Problem creating certificate signing request."); $status->setErrorCode(4112); //Force corrupt file } print $status->out(); return; } else { /* * if CSR file exists, go ahead and use the data from that file to fill in the fields. */ if (file_exists(csrFile)) { error_log("CSR file exists, loading field data."); } else { error_log("CSR file does not exist."); } } ?> Tools - SSL Certificate - Create Signing Request (CSR)


Tools - SSL Certificate - Create Certificate Signing Request


Select Key Length:
Select Digest Algorithm:
Country Code:
State/Province:
Locality:
Common Name:
Organization:
Organizational Unit:
E-Mail Address: Optional

Certificate Signing Request (CSR) Data