note 88645 modified in function.openssl-pkey-get-private by danbrown

From: Date: Wed, 04 Feb 2009 22:08:36 +0000
Subject: note 88645 modified in function.openssl-pkey-get-private by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150232@lists.php.net to get a copy of this message
I also spent hours when trying to find the reason of error: "error getting private key". Sometimes this error appeared, sometimes not. My solution is using the realpath() for every parameter of openssl_pkcs7_sign. In my case the code looks like: <?php $Certif_path = 'certificate/mycertificate.pem'; $clearfile = "certificate/random_name"; $encfile = $clearfile . ".enc"; $clearfile = $clearfile . ".txt"; // ---- // -- fill $clearfile with the mail to be signed ... // ---- openssl_pkcs7_sign(realpath($clearfile), realpath('.').'/'.$encfile, // because $encfile does not exist yet we cannot use realpath($encfile); 'file://'.realpath($Certif_path), array('file://'.realpath($Certif_path), PUBLIC_KEY), array("To" => TO_EMAIL, "From" => FROM_EMAIL, "Subject" => ""), PKCS7_DETACHED)); ?> --was-- I also spent hours when trying to find the reason of error: "error getting private key". Sometimes this error appeared, sometimes not. My solution is using the realpath() for every parameter of openssl_pkcs7_sign. In my case the code looks like: <?php $Certif_path = 'certificate/mycertificate.pem'; $clearfile = "certificate/random_name"; $encfile = $clearfile . ".enc"; $clearfile = $clearfile . ".txt"; // ---- // -- fill $clearfile with the mail to be signed ... // ---- openssl_pkcs7_sign(realpath($clearfile), realpath('.').'/'.$encfile, // because $encfile does not exist yet we cannot use realpath($encfile); 'file://'.realpath($Certif_path), array('file://'.realpath($Certif_path), PUBLIC_KEY), array("To" => TO_EMAIL, "From" => FROM_EMAIL, "Subject" => ""), PKCS7_DETACHED)); ?> http://php.net/manual/en/function.openssl-pkey-get-private.php

« previous php.notes (#150232) next »