DigitalOceanPHP / Client

DigitalOcean API v2 client for PHP
MIT License
710 stars 205 forks source link

Add certificate let`s encrypt #234

Closed John-Henrique closed 4 years ago

John-Henrique commented 5 years ago

I want add let`s encrypt certificate to domain, but reading class I understand how use method create. Can you help me?

I don't understand, looks like very different of documentation https://developers.digitalocean.com/documentation/v2/#certificates

//...
$certificate->create( 'mydomain.com', 'lets_encrypt' );

How give domain, type and name?


    /**
     * @param string $name
     * @param string $privateKey
     * @param string $leafCertificate
     * @param string $certificateChain
     *
     * @throws HttpException
     *
     * @return CertificateEntity
     */
    public function create($name, $privateKey, $leafCertificate, $certificateChain)
    {
        $data = [
            'name' => $name,
            'private_key' => $privateKey,
            'leaf_certificate' => $leafCertificate,
            'certificate_chain' => $certificateChain,
        ];

        $certificate = $this->adapter->post(sprintf('%s/certificates', $this->endpoint), $data);

        $certificate = json_decode($certificate);

        return new CertificateEntity($certificate->certificate);
    }
glennjacobs commented 4 years ago

Doesn't look like LetsEncrypt is supported at present. Have flagged as an enhancement.

GrahamCampbell commented 4 years ago

~Moving to part of the v4 design issue #249. I am planning to smash out a fresh package for v4 which will feel like the old package, but have none of the issues and all of the compatibility. ;)~

EDIT: Implemented this in v3.0.0.