attr('name'); $cert = CertificateQuery::create() ->findOneByUserAndName($this->getUser(), $name); if ($cert === null) { return $this->getResponse()->withStatus(404)->write("Couldn't find your Certificate with the name '{$name}'"); } return $this->getResponse() ->withHeader('Content-Type', 'plain/text') ->withHeader('Content-Disposition', 'attachment; filename="' . $name . '.' . $cert->getSerial() .'.crt"') ->write($cert->getCertificate()); } }