1: <?php
2:
3: namespace Cloudflare\Zone;
4:
5: use Cloudflare\Api;
6: use Cloudflare\Zone;
7:
8: /**
9: * CloudFlare API wrapper
10: *
11: * Keyless SSL for a Zone
12: *
13: * @author James Bell <[email protected]>
14: *
15: * @version 1
16: */
17: class KeylessSSL extends Api
18: {
19: /**
20: * Default permissions level
21: *
22: * @var array
23: */
24: protected $permission_level = ['read' => '#ssl:read', 'edit' => '#ssl:edit'];
25:
26: /**
27: * Create a Keyless SSL configuration (permission needed: #ssl:edit)
28: *
29: * @param string $zone_identifier API item identifier tag
30: * @param string $host The keyless SSL host
31: * @param int $port The keyless SSL port used to commmunicate between CloudFlare and the client's Keyless SSL server
32: * @param string $name The keyless SSL name
33: * @param string $certificate The zone's SSL certificate or SSL certificate and intermediate(s)
34: * @param string|null $bundle_method A ubiquitous bundle is a bundle that has a higher probability of being verified everywhere, even by clients using outdated or unusual trust stores.
35: * An optimal bundle is a bundle with the shortest chain and newest intermediates. A forced method attempt to use the certificate/chain as defined by the input
36: */
37: public function create($zone_identifier, $host, $port, $name, $certificate, $bundle_method = null)
38: {
39: $data = [
40: 'host' => $host,
41: 'port' => $port,
42: 'name' => $name,
43: 'certificate' => $certificate,
44: 'bundle_method' => $bundle_method,
45: ];
46:
47: return $this->post('zones/'.$zone_identifier.'/keyless_certificates', $data);
48: }
49:
50: /**
51: * List Keyless SSLs (permission needed: #ssl:read)
52: *
53: * @param string $zone_identifier API item identifier tag
54: */
55: public function certificates($zone_identifier)
56: {
57: return $this->get('zones/'.$zone_identifier.'/keyless_certificates');
58: }
59:
60: /**
61: * Keyless SSL details (permission needed: #ssl:read)
62: *
63: * @param string $zone_identifier API item identifier tag
64: * @param string $identifier
65: */
66: public function details($zone_identifier, $identifier)
67: {
68: return $this->get('zones/'.$zone_identifier.'/keyless_certificates/'.$identifier);
69: }
70:
71: /**
72: * Update SSL configuration (permission needed: #ssl:edit)
73: *
74: * @param string $zone_identifier API item identifier tag
75: * @param string $identifier
76: * @param string $host The keyless SSL hostname
77: * @param string $name The keyless SSL name
78: * @param int $port The keyless SSL port used to commmunicate between CloudFlare and the client's Keyless SSL server
79: * @param bool|null $enabled Whether or not the Keyless SSL is on or off
80: */
81: public function update($zone_identifier, $identifier, $host, $name, $port, bool $enabled = null)
82: {
83: $data = [
84: 'host' => $host,
85: 'port' => $port,
86: 'name' => $name,
87: 'enabled' => $enabled,
88: ];
89:
90: return $this->patch('zones/'.$zone_identifier.'/keyless_certificates/'.$identifier, $data);
91: }
92:
93: /**
94: * Delete an SSL certificate (permission needed: #ssl:edit)
95: *
96: * @param string $zone_identifier API item identifier tag
97: * @param string $identifier
98: */
99: public function delete_ssl($zone_identifier, $identifier)
100: {
101: return $this->delete('zones/'.$zone_identifier.'/keyless_certificates/'.$identifier);
102: }
103: }
104: