View Issue Details

IDProjectCategoryView StatusLast Update
0000662Main CAcert Websitecertificate issuingpublic2013-01-15 07:56
ReporterWillerZ Assigned ToSourcerer  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Fixed in Version2009 Q2 
Summary0000662: Issuing certificates via the CertAPI facility does not work [solution known]
DescriptionThe CertApi is documented here: http://wiki.cacert.org/wiki/CertApi

The problem occurs in ccsr.php lines 61-71. Currently read:

    $CSR = trim($_REQUEST['optionalCSR']);
    $tmpname = tempnam("/tmp", "CSR");
    $tempnam = tempnam("/tmp", "CSR");
    $fp = fopen($tmpname, "w");
    fputs($fp, $CSR);
    fclose($fp);
    $do = `/usr/bin/openssl req -in $tmpname -out $tempnam`;
    @unlink($tmpfname);
    if(filesize($tempnam) <= 0)
        die("404,Invalid or missing CSR");

This will work the first time it is run and for a lot of times after that but will eventually start to fail because sooner or later it will be impossible to create a file in /tmp. I recommend changing it to read:

    $CSR = trim($_REQUEST['optionalCSR']);
    $incsr = tempnam("/tmp", "CSR");
    $checkedcsr = tempnam("/tmp", "CSR");
    $fp = fopen($incsr, "w");
    fputs($fp, $CSR);
    fclose($fp);
    $do = `/usr/bin/openssl req -in $incsr -out $checkedcsr`;
    @unlink($incsr);
    if(filesize($checkedcsr) <= 0)
        die("404,Invalid or missing CSR:".$do);

Obviously this also requires the later rename to be changed to:

        rename($checkedcsr, $CSRname);

This change also gives the invoker more information than before if their request fails (they will get the openssl req output from processing their CSR).
TagsNo tags attached.
Reviewed by
Test Instructions

Activities

Sourcerer

2009-04-09 19:13

administrator   ~0001358

The code has been improved. We intentionally do not output the OpenSSL errors, due to potential leaks and Cross-Site-Scripting

Issue History

Date Modified Username Field Change
2009-01-01 16:28 WillerZ New Issue
2009-04-09 19:13 Sourcerer Note Added: 0001358
2009-04-09 19:13 Sourcerer Status new => solved?
2009-05-30 23:55 Sourcerer Status solved? => closed
2009-05-30 23:55 Sourcerer Resolution open => fixed
2009-05-30 23:55 Sourcerer Assigned To => Sourcerer
2013-01-15 07:56 Werner Dworak Fixed in Version => 2009 Q2