<?php

chdir(__DIR__);

// restrict to terminal only.
if (php_sapi_name() != 'cli') die('This must be run via CLI');

exec("/usr/bin/openssl genrsa -out ours.key 1024");
exec("/usr/bin/openssl req -new -key ours.key -x509 -days 1825 -out ours.crt");

echo "====" . PHP_EOL;
echo "Now upload this to Paypal: " . realpath('ours.crt') . PHP_EOL;
echo 'https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/encryptedwebpayments/#id08A3I0Q0CQN' . PHP_EOL;
echo 'and save PayPal certificate as ' . __DIR__ . '/paypal.crt' . PHP_EOL;
echo 'and define PAYPAL_CERT_IT in settings' . PHP_EOL;