Skip to content

Instantly share code, notes, and snippets.

@blar
Created February 5, 2015 20:21
Show Gist options
  • Save blar/1b666adf6816b29dc8fa to your computer and use it in GitHub Desktop.
Save blar/1b666adf6816b29dc8fa to your computer and use it in GitHub Desktop.
<?php
$pkcs12file = new SplFileInfo(__DIR__.'/passbook.p12');
if(!file_exists($pkcs12file)) {
$pkcs12 = new Pkcs12();
$file = new SplFileInfo(__DIR__.'/passbook_certificate.pem');
$certificate = new Certificate($file);
$pkcs12->setCertificate($certificate);
$file = new SplFileInfo(__DIR__.'/passbook_key.pem');
$privateKey = new PrivateKey($file);
$pkcs12->setPrivateKey($privateKey);
$file = new SplFileInfo(__DIR__.'/AppleWWDRCA.pem');
$certificate = new Certificate($file);
$pkcs12->setChain($certificate);
$pkcs12->exportToFile($pkcs12file);
}
$pkcs12 = new Pkcs12($pkcs12file);
$manifest = new SplFileInfo(__DIR__.'/manifest.json');
$signature = Pkcs7::signWithPkcs12($manifest, $pkcs12, PKCS7_BINARY | PKCS7_DETACHED);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment