acmesh-official / acme.sh

A pure Unix shell script implementing ACME client protocol
https://acme.sh
GNU General Public License v3.0
38.67k stars 4.91k forks source link

Incorrect use of Plesk API to get list of domains #4735

Open eg321 opened 1 year ago

eg321 commented 1 year ago

Steps to reproduce

I'm using acme behind PFSense's Acme service. So my STR is simple:

  1. Create new configuration with "DNS-Plesk" method.
  2. Try to issue certificate.

Actual result

Operation failed with message: Are you sure that this domain is managed by this Plesk server? Error add txt for domain:_acme-challenge.yyy.com

Additional info

As I can see, there is incorrect call to Plesk API to get list of domains - it's trying to get list of webspaces instead of domains. Webspaces it's like "subscription" in Plesk term and can contain several domains inside. Webspace name is not website name in general case. It looks like it was broken by @lufi42 with that commit: a6b58bc88d390a21baf3cf457f3d3daba314222b I've reverted this specific commit and it's working for me again. @lufi42, can you check if your case can be fixed in other manner, not broking case described above please? Please let me know, if you need any additional information.

Debug log (i've replaced some domain names, usernames and other private info)

[Mon Aug 14 02:08:01 +07 2023] Test login to Plesk XML API successful. Login credentials and URI successfully saved to the acme.sh configuration file for future use.
[Mon Aug 14 02:08:01 +07 2023] Identifying DNS root domain for '_acme-challenge.yyy.com' that is managed by the Plesk account.
[Mon Aug 14 02:08:01 +07 2023] Querying Plesk server for list of managed domains...
[Mon Aug 14 02:08:01 +07 2023] Entered _call_api(). Calling Plesk XML API with request:
[Mon Aug 14 02:08:01 +07 2023] '<packet><webspace><get><filter/><dataset><gen_info/></dataset></get></webspace></packet>'
[Mon Aug 14 02:08:01 +07 2023] POST
[Mon Aug 14 02:08:01 +07 2023] _post_url='https://spl93.hosting.reg.ru:8443/enterprise/control/agent.php'
[Mon Aug 14 02:08:01 +07 2023] body='<packet><webspace><get><filter/><dataset><gen_info/></dataset></get></webspace></packet>'
[Mon Aug 14 02:08:01 +07 2023] _postContentType
[Mon Aug 14 02:08:01 +07 2023] Http already initialized.
[Mon Aug 14 02:08:01 +07 2023] _CURL='curl --silent --dump-header /tmp/acme/_.yyy.com/http.header  -L  -g '
[Mon Aug 14 02:08:01 +07 2023] _ret='0'
[Mon Aug 14 02:08:01 +07 2023] The responses from the Plesk XML server were:
[Mon Aug 14 02:08:01 +07 2023] retcode=0. Literal response:
[Mon Aug 14 02:08:01 +07 2023] '<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.9.1">
  <webspace>
    <get>
      <result>
        <status>ok</status>
        <filter-id>6631</filter-id>
        <id>6631</id>
        <data>
          <gen_info>
            <cr_date>2021-08-02</cr_date>
            <name>u1437yyy.plsk.regruhosting.ru</name>
            <ascii-name>u1437yyy.plsk.regruhosting.ru</ascii-name>
            <status>0</status>
            <real_size>3522068480</real_size>
            <owner-id>14391</owner-id>
            <dns_ip_address>3.3.1.2</dns_ip_address>
            <htype>vrt_hst</htype>
            <guid>4557aeas-bb06-49f8-a869-24118c1515e5</guid>
            <vendor-guid>cvbn73d5-3b97-425c-bf77-7a06fc0a535c</vendor-guid>
            <external-id/>
            <sb-site-uuid/>
            <description/>
          </gen_info>
        </data>
      </result>
    </get>
  </webspace>
</packet>'
[Mon Aug 14 02:08:01 +07 2023] statuslines_count_total=1.
[Mon Aug 14 02:08:01 +07 2023] statuslines_count_okay=1.
[Mon Aug 14 02:08:01 +07 2023] Leaving _call_api(). Successful call.
[Mon Aug 14 02:08:01 +07 2023] Domains managed by Plesk server are (ignore the hacked output):
[Mon Aug 14 02:08:01 +07 2023]         <status>ok</status>        <filter-id>6631</filter-id>        <id>6631</id>        <data>          <gen_info>            <cr_date>2021-08-02</cr_date>            <name>u1437yyy.plsk.regruhosting.ru</name>            <name>u1437yyy.plsk.regruhosting.ru</name>            <status>0</status>            <real_size>3522068480</real_size>            <owner-id>1439</owner-id>            <dns_ip_address>3.3.1.2</dns_ip_address>            <htype>vrt_hst</htype>            <guid>aaaaaac-bb06-49f8-a869-24118c1515e5</guid>            <vendor-guid>aaaaa3d5-3b97-425c-bf77-7a06fc0a535c</vendor-guid>            <external-id/>            <sb-site-uuid/>            <description/>          </gen_info>        </data>
[Mon Aug 14 02:08:01 +07 2023] Checking if '_acme-challenge.yyy.com' is managed by the Plesk server...
[Mon Aug 14 02:08:01 +07 2023] No match, trying next parent up...
[Mon Aug 14 02:08:01 +07 2023] Checking if 'yyy.com' is managed by the Plesk server...
[Mon Aug 14 02:08:01 +07 2023] No match, and next parent would be a TLD...
[Mon Aug 14 02:08:01 +07 2023] Cannot find '_acme-challenge.yyy.com' or any parent domain of it, in Plesk.
[Mon Aug 14 02:08:01 +07 2023] Are you sure that this domain is managed by this Plesk server?
[Mon Aug 14 02:08:01 +07 2023] Error add txt for domain:_acme-challenge.yyy.com
[Mon Aug 14 02:08:01 +07 2023] _on_issue_err
[Mon Aug 14 02:08:01 +07 2023] Please check log file for more details: /tmp/acme/_.yyy.com/acme_issuecert.log
github-actions[bot] commented 1 year ago

Please upgrade to the latest code and try again first. Maybe it's already fixed. acme.sh --upgrade If it's still not working, please provide the log with --debug 2, otherwise, nobody can help you.

lufi42 commented 1 year ago

@eg321 can you please tell which Plesk Edition you are using? It looks like Plesk has different behaviours in their editions: Web Host/Web Pro/Web Admin, see: https://www.plesk.com/editions/

You can find this information in your Plesk Admin Panel here: [Tools & Settings -> Plesk -> About Plesk] Please provide Version & Edition information. Thank you.

eg321 commented 1 year ago

@lufi42 it's a shared hosting on reg.ru provider, so it's a definitely WEB HOST EDITION. I don't have admin access, but it's a Plesk 18 "Obsidian" (I see <meta name="plesk-build" content="1800230428.12"> header).

I don't have other Plesk versions to check, but it's definitely strange that you request webspaces to get domains. Is it really returns also all domains on your version? or maybe it works, because you have only single domain in that webspace and they have same name?