tschoffelen / php-pkpass

💳 PHP class for creating passes for Wallet on iOS.
https://includable.com
MIT License
908 stars 187 forks source link

Error: Could not read the certificate #34

Closed tonit82 closed 11 years ago

tonit82 commented 11 years ago

Hi guys,

I'm new to pkpass and I'm fiddling around to make example.php work. I've followed the steps as described on the readme file by getting a certificate converting it to .p12 using Keychain Access. I have the correct password for the certificate. Downloaded the AppleWWDRCA.cer and converted it to .pem with the Keychain Access. I've entered the correct passTypeIdentifier and teamIdentifier on lines 15 and 17. All the required files have been uploaded on my server where I'm doing the test.

This is what I have entered on the example.php on the parameters required:

$pass->setCertificate('../certificate/Key2Vegas Passbook.p12'); // 2. Set the path to your Pass Certificate (.p12 file) $pass->setCertificatePassword('****'); // 2. I have the correct password, used the asterisks for security reasons $pass->setWWDRcertPath('../AppleWWDRCA.pem'); // 3. Set the path to your WWDR Intermediate certificate (.pem file)

// Top-Level Keys http://developer.apple.com/library/ios/#documentation/userexperience/Reference/PassKit_Bundle/Chapters/TopLevel.html $standardKeys = array( 'description' => 'Demo pass', 'formatVersion' => 2, 'organizationName' => 'Key2Vegas', 'passTypeIdentifier' => 'pass.key2vegas.bcpass', // 4. Set to yours 'serialNumber' => '123456', 'teamIdentifier' => 'UU4Z3K5423' // 4. Set to yours );

I know the pkpass class uses the openssl_pkcs12_read function and I know that there is where my problem is. The php version on my server is > 5.

I want to know why the class can not read the certificate? Why is it giving me a Error: Could not read the certificate message?

Thanks in advance.

ptz0n commented 11 years ago

Are you sure that PHP have the appropriate permissions to read the certificate file? You can try the following code, and rename your cert file to not have any whitespace.

<?php
$filename = '../certificate/Key2Vegas-Passbook.p12';
if (is_readable($filename)) {
    echo 'The file is readable';
} else {
    echo 'The file is not readable';
}
tonit82 commented 11 years ago

I renamed the certificate name to Key2VegasPassbook.p12 and tried the is_readable function. The result is the file could not be read by the php. It seems my PHP doesn't have the right permissions to read the certificate.

Can you give me any directions on how to give PHP right permissions to read the certificate?

ptz0n commented 11 years ago

@tonit82 It depends on what environment your using. Try this guide for OS X or the following for Linux:

$ chmod 777 Key2Vegas-Passbook.p12
tonit82 commented 11 years ago

Yeah, I tried it with 755 actually I will give it a try with 777 also.

Thanks

ptz0n commented 11 years ago

@tonit82 Make sure the certificate path is correct relative to your sample file. Place the certificate in the same directory and use:

$pass->setCertificate('Key2VegasPassbook.p12');
ptz0n commented 11 years ago

@tonit82 Still not working for you?

PS. @tschoffelen Maybe close this one? DS.

elbombillopublic commented 11 years ago

I'm working with Teodor, we are getting this error message.

openssl_pkcs12_read echo openssl_error_string()

File exists error:0D06B08E:asn1 encoding routines:ASN1_D2I_READ_BIO:not enough data

ptz0n commented 11 years ago

@elbombillopublic Which OpenSSL version are you running?

elbombillopublic commented 11 years ago

OpenSSL 1.0.0-fips 29 Mar 2010

sirhcmcd commented 11 years ago

I have the same issue as listed above, but can't find the resolution anywhere... any advice?

thanks

sirhcmcd commented 11 years ago

I figured out my issue... I put all the files in the same folder (including PKPass.php and certs) with my updated example.php then it worked. I have since updated the files to be in the right location and permissions.

cjt3007 commented 10 years ago

Having the "could not read" issue, but permissions are set to 777, and php can read the files using the is_readable function. Help?

lock[bot] commented 6 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.