Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activate SSL-Certificate on Domain via Plesk XML API

I'm currently working on a Plesk-Panel Plugin for automatically getting & installing SSL-certificates. With the very powerful XML API provided by Parallels I'm able to install the certificate to Plesks SSL Cert-Pool.

It's also possible to turn SSL on for a specific page, but I can absolutely find no way to activate a specific certificate (which is, of course, already added to the certificate pool).

The easiest answer of course would be "the API doesn't support it", but it's very easy to do this via the Command Line Utilities using this command:

/opt/psa/bin/subscription -u example.com -certificate-name my_cool_ssl_cert

and regarding to the manual,

The Command-Line Interface (CLI) has the same functions as API RPC

which is relatively obvious, because they have the same functionality everywhere else.

So what point do I miss? Has anybody done this before?

Without the possibility to activate a specific via the XML-API, many of the calls would be completely senseless (It's possible to install a CERT, activate ssl but not to activate it? Can't really believe this.)

I'd really appreciate any answer/comment that points me to the right direction, thanks in advance!

like image 444
tillz Avatar asked Oct 20 '22 19:10

tillz


1 Answers

Here the request example:

<packet>
    <webspace>
        <set>
            <filter>
                <id>34</id>
            </filter>
            <values>
                <hosting>
                    <vrt_hst>

                        <property>

                            <name>certificate_name</name>

                            <value>some_existed_certificate_name</value>

                        </property>

                    </vrt_hst>
                </hosting>
            </values>
        </set>  
    </webspace>
</packet>

Main rule is that if in CLI it's an "subscription" setting, than we go to "Managing Subscriptions (Webspaces)" -> "Setting Subscription Parameters" and we always have to check "Request Packet Structure". From packet structure we guess that our SSL setting should be in hosting part and there is a link, so we going to

http://download1.parallels.com/Plesk/PP12/12.0/Doc/en-US/online/plesk-api-rpc/39967.htm

but there we see that this part of API is not fully documented, there some "properties" but obviously not all of them. And there is a note

Note: To manage hosting settings, you should first retrieve a hosting settings descriptor, containing names of the settings. For details, refer to the Retrieving Descriptor of Hosting Settings section.

And by this new link we can find how to retrieve an list of all names of hosting properties where we find "certificate_name".

For addon domain or subdomain you can use following query:

<packet>
    <site>
        <set>
            <filter>
                <id>3</id>
            </filter>
            <values>
                <hosting>
                    <vrt_hst>

                        <property>

                            <name>certificate_name</name>

                            <value>some_existed_certificate_name</value>

                        </property>

                    </vrt_hst>
                </hosting>
            </values>
        </set>  
    </site>
</packet>
like image 63
Oleg Neumyvakin Avatar answered Oct 22 '22 23:10

Oleg Neumyvakin