public function test() { $signedCertificate = SignedCertificate::fromBinaryEncodedDer(file_get_contents(__DIR__ . '/../../Stubs/signed.certificate.cer')); $this->assertTrue(is_resource($signedCertificate->asResource())); $this->assertStringStartsWith('-----BEGIN CERTIFICATE-----', (string) $signedCertificate); }
/** * @param SigningRequest $request * @param Type $type * @param $appIdId * @return SignedCertificate * @throws ApplePortalException */ public function signCertificate(SigningRequest $request, Type $type, $appIdId) { $this->initialize(); $createCertificateResponse = $this->client->post('https://developer.apple.com/services-account/QH65B2/account/ios/certificate/submitCertificateRequest.action', ['cookies' => $this->cookieJar, 'headers' => $this->csrfTokens, 'form_params' => ['teamId' => $this->teamId, 'type' => (string) $type, 'csrContent' => (string) $request, 'appIdId' => $appIdId]]); $certificatePayload = (string) $createCertificateResponse->getBody(); if (strpos($certificatePayload, 'already')) { throw new ApplicationAlreadyHasPushCertificateException('There are too many push certificates for this app'); } $certificateJson = json_decode($certificatePayload, true); $certificateId = $certificateJson['certRequest']['certificate']['certificateId']; $certificateDownloadResponse = $this->client->get('https://developer.apple.com/services-account/QH65B2/account/ios/certificate/downloadCertificateContent.action', ['cookies' => $this->cookieJar, 'headers' => $this->csrfTokens, 'query' => ['teamId' => $this->teamId, 'type' => (string) $type, 'certificateId' => $certificateId]]); return SignedCertificate::fromBinaryEncodedDer((string) $certificateDownloadResponse->getBody()); }
public function test() { $cert = new PushCertificate(new PrivateKey(), SignedCertificate::fromBinaryEncodedDer(file_get_contents(__DIR__ . '/../../Stubs/signed.certificate.cer'))); $this->assertSame((string) $cert, (string) $cert->getSignedCertificate() . (string) $cert->getPrivateKey()); $this->assertSame((string) $cert->getSignedCertificate() . (string) $cert->getPrivateKey(), (string) PushCertificate::fromString((string) $cert->getSignedCertificate() . (string) $cert->getPrivateKey())); }