1: <?php
2:
3: namespace Cloudflare;
4:
5: /**
6: * CloudFlare API wrapper
7: *
8: * CloudFlare CA
9: * API to create CloudFlare-issued SSL certificates that can be installed on your origin server.
10: * Use your Certificates API Key as your User Service Key when calling these endpoints
11: * (see the section on request headers for details)
12: *
13: * @author James Bell <[email protected]>
14: *
15: * @version 1
16: */
17: class Certificates extends Api
18: {
19: /**
20: * Default permissions level
21: *
22: * @var array
23: */
24: protected $permission_level = ['read' => null, 'edit' => null];
25:
26: /**
27: * List Certificates
28: * List all existing CloudFlare-issued Certificates for a given zone. Use your Certificates API Key as your
29: * User Service Key when calling this endpoint
30: */
31: public function certificates($page = null, $per_page = null, $direction = null)
32: {
33: return $this->get('certificates', $data);
34: }
35:
36: /**
37: * Create Certificate
38: * Create a CloudFlare-signed certificate. Use your Certificates API Key as your User Service Key when
39: * calling this endpoint
40: *
41: * @param array $hostnames Array of hostnames or wildcard names (e.g., *.example.com) bound to the certificate
42: * @param string $request_type Signature type desired on certificate ("origin-rsa" (rsa), "origin-ecc" (ecdsa), or "keyless-certificate" (for Keyless SSL servers)
43: * @param string $csr The Certificate Signing Request (CSR). Must be newline-encoded.
44: * @param int|null $requested_validity The number of days for which the certificate should be valid
45: */
46: public function create($hostnames, $request_type, $csr, $requested_validity = null)
47: {
48: $data = [
49: 'hostnames' => $hostnames,
50: 'request_type' => $request_type,
51: 'csr' => $csr,
52: 'requested_validity' => $requested_validity,
53: ];
54:
55: return $this->post('certificates', $data);
56: }
57:
58: /**
59: * Certificate Details
60: * Get an existing certificate by its serial number. Use your Certificates API Key as your User Service Key
61: * when calling this endpoint
62: *
63: * @param string $identifier API item identifier tag
64: */
65: public function details($identifier)
66: {
67: return $this->get('certificates/'.$identifier);
68: }
69:
70: /**
71: * Revoke certificate
72: * Revoke a created certificate for a zone. Use your Certificates API Key as your User Service Key when
73: * calling this endpoint
74: *
75: * @param string $identifier API item identifier tag
76: */
77: public function revoke($identifier)
78: {
79: return $this->delete('certificates/'.$identifier);
80: }
81: }
82: