Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

Commit

Permalink
Added Cloudflare CA support
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesryanbell committed Jun 5, 2016
1 parent 912e49f commit 10705fd
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -2,7 +2,7 @@
"name": "jamesryanbell/cloudflare",
"description": "Cloudflare API V4 PHP wrapper",
"license": "MIT",
"version": "1.1.0",
"version": "1.2.0",
"keywords": ["cloudflare", "api"],
"authors": [
{
Expand Down
78 changes: 78 additions & 0 deletions src/CloudFlare/Certificates.php
@@ -0,0 +1,78 @@
<?php

namespace Cloudflare;

/**
* CloudFlare API wrapper
*
* CloudFlare CA
* API to create CloudFlare-issued SSL certificates that can be installed on your origin server.
* Use your Certificates API Key as your User Service Key when calling these endpoints
* (see the section on request headers for details)
*
* @author James Bell <james@james-bell.co.uk>
* @version 1
*/

class Certificates extends Api
{
/**
* Default permissions level
* @var array
*/
protected $permission_level = array('read' => null, 'edit' => null);

/**
* List Certificates
* List all existing CloudFlare-issued Certificates for a given zone. Use your Certificates API Key as your
* User Service Key when calling this endpoint
*/
public function certificates($page = null, $per_page = null, $direction = null)
{
return $this->get('certificates', $data);
}

/**
* Create Certificate
* Create a CloudFlare-signed certificate. Use your Certificates API Key as your User Service Key when
* calling this endpoint
* @param array $hostnames Array of hostnames or wildcard names (e.g., *.example.com) bound to the certificate
* @param string $request_type Signature type desired on certificate ("origin-rsa" (rsa), "origin-ecc" (ecdsa), or "keyless-certificate" (for Keyless SSL servers)
* @param string $csr The Certificate Signing Request (CSR). Must be newline-encoded.
* @param int|null $requested_validity The number of days for which the certificate should be valid
*/
public function create($hostnames, $request_type, $csr, $requested_validity = null)
{
$data = array(
'hostnames' => $hostnames,
'request_type' => $request_type,
'csr' => $csr,
'requested_validity' => $requested_validity
);
return $this->post('certificates', $data);
}


/**
* Certificate Details
* Get an existing certificate by its serial number. Use your Certificates API Key as your User Service Key
* when calling this endpoint
* @param string $identifier API item identifier tag
*/
public function details($identifier)
{
return $this->get('certificates/' . $identifier);
}

/**
* Revoke certificate
* Revoke a created certificate for a zone. Use your Certificates API Key as your User Service Key when
* calling this endpoint
* @param string $identifier API item identifier tag
*/
public function revoke($identifier)
{
return $this->delete('certificates/' . $identifier);
}

}

0 comments on commit 10705fd

Please sign in to comment.