/** * Get the certificate with key $key in a deployable from for the specified * browser. * * Usually this means some kind of JavaScript to install it to the keystore, * but sometimes it suffices to send the certificate with the right MIME-type * to the browser. * * @param $key The order-number/auth-key for the certificate * @param $browser The browser for which the certificate should be returned * Current legal values for that: * msie_post_vista: return full chain as PKCS7 in JavaScript * msie_pre_vista: return full chain as PKCS7 in JavaScript * keygen: return certificate only as string enclosed base64-encoded PKCS7 */ public function getCertDeploymentScript($key, $browser) { $key = $this->transformToOrderNumber($key); switch ($browser) { case "msie_post_vista": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=1" . "&responseType=2" . "&responseEncoding=2" . "&responseMimeType=text/javascript" . "&callbackFunctionName=installIEVistaCertificate"; $data = CurlWrapper::curlContact($collect_endpoint); return "<script type=\"text/javascript\">{$data}</script>"; break; case "msie_pre_vista": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=1" . "&responseType=2" . "&responseEncoding=2" . "&responseMimeType=text/javascript" . "&callbackFunctionName=installIEXPCertificate"; $data = CurlWrapper::curlContact($collect_endpoint); return "<script type=\"text/javascript\">{$data}</script>"; break; case "chrome": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=2" . "&responseType=3" . "&responseEncoding=0"; /* encode base-64 */ $data = CurlWrapper::curlContact($collect_endpoint); $cert = new Certificate(trim(substr($data, 2))); $der_cert = $cert->getDERContent(true); return $der_cert; break; case "mozilla": case "safari": case "opera": $collect_endpoint = ConfusaConstants::$CAPI_COLLECT_ENDPOINT . "?loginName=" . $this->account->getLoginName() . "&loginPassword="******"&orderNumber=" . $key . "&queryType=2" . "&responseType=3" . "&responseEncoding=0"; /* encode base-64 */ $data = CurlWrapper::curlContact($collect_endpoint); return trim(substr($data, 2)); break; default: throw new ConfusaGenException("Deployment in browser {$browser} not supported"); break; } }