Assign certificate to domain with plesk cli

22 Views Asked by At

For some time, I have been trying to assign a certificate to a domain.

I use the Plesk CLI and I manage to create a certificate with the files it asks me (keyfile, cacert.cert etc)

$response = $this->httpClient->request('POST', 'https://'.$domain->getHostingServer()->getHostname().'/api/v2/cli/certificate/call', [
        'headers' => [
            'X-API-Key' => $domain->getHostingServer()->getApiKey(),
        ],
        'json' => [
            'params' => [
               '--create',
                $domain->getName().'-certificate',
               '-domain',
               $domain->getName(),
                '-key-file',
                '/var/www/vhosts/'.$domain->getName().'/httpdocs/'.$domain->getName().'-keyfile.key',
                '-cert-file',
                '/var/www/vhosts/'.$domain->getName().'/httpdocs/'.$domain->getName().'-cert.cert',
                '-cacert-file',
                '/var/www/vhosts/'.$domain->getName().'/httpdocs/'.$domain->getName().'-cacert.cert',
                '-csr-file',
                '/var/www/vhosts/'.$domain->getName().'/httpdocs/'.$domain->getName().'-csreq.csr',
            ],
        ],
    ]);

Perfect ! I found my certificate on the domain of my server, from what I could see on the doc and internet, this certificate must be assigned.

so I executed what the Plesk doc says:

 $response = $this->httpClient->request('POST', 'https://'.$domain->getHostingServer()->getHostname().'/api/v2/cli/certificate/call', [
        'headers' => [
            'X-API-Key' => $domain->getHostingServer()->getApiKey(),
        ],
        'json' => [
            'params' => [
                '--assign-cert',
                $domain->getName().'-certificate',
                '-domain',
                $domain->getName(),
                '-ip',
                'MyHIdeIp'
            ],
        ],
    ]);

plesk returns to me: SSL/TLS certificate 'myCertificate' was successfully assigned to IP address MyHideIp"

Only I don't see my domain with this active certificate.

CLI PLESK DOC: https://docs.plesk.com/en-US/obsidian/cli-linux/using-command-line-utilities/certificate-ssltls-certificates.39009/

0

There are 0 best solutions below