public function set($site_env, $certificate, $private_key, $options = ['intermediate-certificate' => null])
{
list(, $env) = $this->getSiteEnv($site_env);
$key = ['cert' => file_exists($certificate) ? trim(file_get_contents($certificate)) : $certificate, 'key' => file_exists($private_key) ? trim(file_get_contents($private_key)) : $private_key];
if (!is_null($int = $options['intermediate-certificate'])) {
if (file_exists($int)) {
$key['intermediary'] = trim(file_get_contents($int));
} else {
$key['intermediary'] = $int;
}
}
// Set the key for the environment.
$workflow = $env->setHttpsCertificate($key);
// Wait for the workflow to complete.
$this->log()->notice('SSL certificate updated. Converging loadbalancer.');
while (!$workflow->checkProgress()) {
// @TODO: Add Symfony progress bar to indicate that something is happening.
}
$this->log()->notice($workflow->getMessage());
}