Move The Custom SSL To An Array

This kinda kicks the can down the road, but allows me to appease PHPMD
(for now)
This commit is contained in:
Phil Young
2021-06-22 10:34:28 +01:00
parent be886c36cb
commit fd34eaf813
2 changed files with 12 additions and 10 deletions

View File

@@ -34,8 +34,7 @@ class CustomHostnames implements API
* @param string $customOriginServer * @param string $customOriginServer
* @param bool $wildcard * @param bool $wildcard
* @param string $bundleMethod * @param string $bundleMethod
* @param string $customKey * @param array $customSsl
* @param string $customCertificate
* @return \stdClass * @return \stdClass
*/ */
public function addHostname( public function addHostname(
@@ -47,8 +46,7 @@ class CustomHostnames implements API
string $customOriginServer = '', string $customOriginServer = '',
bool $wildcard = false, bool $wildcard = false,
string $bundleMethod = '', string $bundleMethod = '',
string $customKey = '', array $customSsl = []
string $customCertificate = ''
): \stdClass { ): \stdClass {
$options = [ $options = [
'hostname' => $hostname, 'hostname' => $hostname,
@@ -68,12 +66,12 @@ class CustomHostnames implements API
$options['ssl']['bundle_method'] = $bundleMethod; $options['ssl']['bundle_method'] = $bundleMethod;
} }
if (!empty($customKey)) { if (!empty($customSsl['key'])) {
$options['ssl']['custom_key'] = $customKey; $options['ssl']['custom_key'] = $customSsl['key'];
} }
if (!empty($customCertificate)) { if (!empty($customSsl['certificate'])) {
$options['ssl']['custom_certificate'] = $customCertificate; $options['ssl']['custom_certificate'] = $customSsl['certificate'];
} }
$zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options); $zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options);

View File

@@ -47,6 +47,7 @@ bsrBsljYfVvtLQzilugs1oEe94LTrYjR2oQt0W24bqpGQHuv1ILuUBuodERkxSFL
/cMkj3wSfC341hFaJEuG1+PcxA== /cMkj3wSfC341hFaJEuG1+PcxA==
-----END PRIVATE KEY----- -----END PRIVATE KEY-----
KEY; KEY;
$customCertificate = <<<CERTIFICATE $customCertificate = <<<CERTIFICATE
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIDmTCCAoGgAwIBAgIULyaeNqp0tOut/wvuxNyKmUxOGYEwDQYJKoZIhvcNAQEL MIIDmTCCAoGgAwIBAgIULyaeNqp0tOut/wvuxNyKmUxOGYEwDQYJKoZIhvcNAQEL
@@ -101,6 +102,7 @@ CERTIFICATE;
'http3' => 'on', 'http3' => 'on',
'min_tls_version' => '1.2' 'min_tls_version' => '1.2'
]; ];
$hostname->addHostname( $hostname->addHostname(
'023e105f4ecef8ad9ca31a8372d0c353', '023e105f4ecef8ad9ca31a8372d0c353',
'app.example.com', 'app.example.com',
@@ -110,8 +112,10 @@ CERTIFICATE;
'origin.example.com', 'origin.example.com',
true, true,
'optimal', 'optimal',
$customKey, [
$customCertificate 'key' => $customKey,
'certificate' => $customCertificate,
]
); );
$this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $hostname->getBody()->result->id); $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $hostname->getBody()->result->id);
} }