Pular para conteúdo

SSL Subdomínios

Adicionar certificado

Adiciona um certificado para um subdomínio.

POST /v1/ssl/certificate/{dominio}/subdomain
$ curl -i https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain \
-X POST \
-H 'Content-Type: application/json' \
-H 'GoCache-Token: meu_token' \
-d '{"certificate": "-----BEGIN CERTIFICATE-----
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-----END CERTIFICATE-----",
    "privatekey": "-----BEGIN PRIVATE KEY-----
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
-----END PRIVATE KEY-----",
    "subdomain": "www.meudominio.com.br"}'
<?php

$ch = curl_init("https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain");

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$headers = array(
                    "Content-Type: application/json",
                    "GoCache-Token: meu_token"
                );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$json = json_encode(array(
                                "certificate" => "-----BEGIN CERTIFICATE-----
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-----END CERTIFICATE-----",
                                "privatekey" => "-----BEGIN PRIVATE KEY-----
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
-----END PRIVATE KEY-----",
                                "subdomain" => "www.meudominio.com.br"
                            )
                        );

curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);
?>

Parâmetros

Campo Tipo Opcional Descrição
certificate String Certificado que será inserido.
privatekey String Chave privada do certificado inserido.
subdomain String Subdomínio no qual o certificado será inserido.
HTTP/1.1 200 OK
{
    "response": {
        "certificates": [
            {
                "san": {},
                "cn": "meudominio.com.br",
                "type": "custom",
                "enabled": true,
                "issueDate": "2022-10-25T16:22:23Z",
                "expirationDate": "2027-01-22T16:22:23Z"
            },
            {
                "san": [
                    "www.meudominio.com.br"
                ],
                "cn": "www.meudominio.com.br",
                "type": "subdomain",
                "subdomain": "www.meudominio.com.br",
                "enabled": true,
                "issueDate": "2023-01-27T12:48:36Z",
                "expirationDate": "2027-04-26T12:48:36Z"
            }
        ],
        "msg": "Success"
    }
}
<?php

if( $statusCode == 200 ) {

    echo("Sucesso!\n");

    $obj = json_decode($response);

    echo("Resultado: Encontrados " . count($obj->response->certificates) . " certificados\n");

}
?>

Listar certificados

Listar todos os certificados de um domínio, inclui os certificados de subdomínio e também os certificados custom e automático do domínio

GET /v1/ssl/certificate/{dominio}/subdomain
$ curl -i https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain \
-X GET \
-H 'GoCache-Token: meu_token'
<?php

$ch = curl_init("https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$headers = array(
                    "GoCache-Token: meu_token"
                );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);
?>

HTTP/1.1 200 OK
{
    "response": {
        "certificates": [
            {
                "san": {},
                "cn": "meudominio.com.br",
                "type": "custom",
                "enabled": true,
                "issueDate": "2022-10-25T16:22:23Z",
                "expirationDate": "2027-01-22T16:22:23Z"
            },
            {
                "san": [
                    "www.meudominio.com.br"
                ],
                "cn": "www.meudominio.com.br",
                "type": "subdomain",
                "subdomain": "www.meudominio.com.br",
                "enabled": true,
                "issueDate": "2023-01-27T12:48:36Z",
                "expirationDate": "2027-04-26T12:48:36Z"
            }
        ]
    }
}
<?php

if( $statusCode == 200 ) {

    echo("Sucesso!\n");

    $obj = json_decode($response);

    echo("Resultado: Encontrados " . count($obj->response->certificates) . " certificados\n");

}
?>

Atualizar certificado

Atualiza certificado configurado para um subdomínio.

PUT /v1/ssl/certificate/{dominio}/subdomain
$ curl -i https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain \
-X PUT \
-H 'Content-Type: application/json' \
-H 'GoCache-Token: meu_token' \
-d '{"certificate": "-----BEGIN CERTIFICATE-----
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-----END CERTIFICATE-----",
    "privatekey": "-----BEGIN PRIVATE KEY-----
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
-----END PRIVATE KEY-----",
    "subdomain": "www.meudominio.com.br"}'
<?php

$ch = curl_init("https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain");

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$headers = array(
                    "Content-Type: application/json",
                    "GoCache-Token: meu_token"
                );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$json = json_encode(array(
                                "certificate" => "-----BEGIN CERTIFICATE-----
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-----END CERTIFICATE-----",
                                "privatekey" => "-----BEGIN PRIVATE KEY-----
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
-----END PRIVATE KEY-----",
                                "subdomain" => "www.meudominio.com.br"
                            )
                        );

curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);
?>

Parâmetros

Campo Tipo Opcional Descrição
certificate String Certificado que será atualizado.
privatekey String Chave privada do certificado atualizado.
subdomain String Subdomínio no qual o certificado será atualizado.
HTTP/1.1 200 OK
{
    "response": {
        "certificates": [
            {
                "san": {},
                "cn": "meudominio.com.br",
                "type": "custom",
                "enabled": true,
                "issueDate": "2022-10-25T16:22:23Z",
                "expirationDate": "2027-01-22T16:22:23Z"
            },
            {
                "san": [
                    "www.meudominio.com.br"
                ],
                "cn": "www.meudominio.com.br",
                "type": "subdomain",
                "subdomain": "www.meudominio.com.br",
                "enabled": true,
                "issueDate": "2023-01-27T12:48:36Z",
                "expirationDate": "2027-04-26T12:48:36Z"
            }
        ],
        "msg": "Success"
    }
}
<?php

if( $statusCode == 200 ) {

    echo("Sucesso!\n");

    $obj = json_decode($response);

    echo("Resultado: " . count($obj->response->certificates) . "\n");

}
?>

Remover certificado

Remove o certificado de um subdomínio

DELETE /v1/ssl/certificate/{dominio}/subdomain/{subdomain}
$ curl -i https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain/www.meudominio.com.br \
-X DELETE \
-H 'GoCache-Token: meu_token'
<?php

$ch = curl_init("https://api.gocache.com.br/v1/ssl/certificate/meudominio.com.br/subdomain/www.meudominio.com.br");

curl_setopt($ch, CURLOPT_DELETE, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$headers = array(
                    "GoCache-Token: meu_token"
                );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);
?>

Parâmetros

Campo Tipo Opcional Descrição
subdomain String Subdomínio que terá o certificado removido.
HTTP/1.1 200 OK
{
    "response": {
        "msg": "Success"
    }
}
<?php

if( $statusCode == 200 ) {

    echo("Sucesso!\n");

    $obj = json_decode($response);

    echo("Resultado: " . $obj->response->msg);

}
?>