-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report bugs to cPanel dns api #3732
Comments
Hi! docker exec acme.sh --issue --force --log --dns dns_cpanel -d subdomain.domain.com [Mon Oct 11 10:52:13 UTC 2021] Getting domain auth token for each domain This error of matching root domain also i have with domain or other subdomain. [Mon Oct 11 10:41:36 UTC 2021] timeout= Also i test with manual (--dns Thanks. |
result is: {"cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}} Your username or api token is not right. |
No it is correct, also I deleted and created newly but always say same error, maybe it is other problem? |
May I ask how you have configured your username, token and url inside the docker container? |
Inside -v /share/acme account.conf i put export cPanel_Username=username, export cPanel_Apitoken=xxxxxxxxxx, export cPanel_Hostname=https://url:2083 , if i put wrong url it dont connect and if i put incorrect username o apitoken return [Tue Oct 12 18:04:43 UTC 2021] cPanel Login failed for user username111 and return this in account.conf: But without luck always same message: |
I cannot say why it fails for you.
works for me (note I used LE's staging environment). |
You can test your api key with
Of course replace CPANEL_ADMIN_ACCOUNT and CPANEL_TOKEN with your settings... |
Hello, I'm trying to the the cPanel API with NameCheap cPanel. This fails. The command appears to have the error: Log attached: Note: I tried testing the API key with: |
[Fri Oct 15 22:05:54 EDT 2021] url='premium131.web-hosting.com:2083/json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzones' From the log it looks like you have set the URL to premium131.web-hosting.com without the https cPanel_Hostname=https://premium131.web-hosting.com It might be confusing to people that i named the variable Hostname and not URL. A hostname is only a name wereas a URL can/may be prefixed with protocol (http://, https://, ftp:// etc) |
I want to slap myself now. Thanks! |
Finally i solve it, with hosting and api token, now i can run command without issues. |
This script does not work when a subdomain is the main cPanel domain. For example, my CP account domain is sub.example.com so it should add DNS record to the sub.example.com zone but instead it tried to add it to the example.com zone. |
Yes, this was how I made the script. |
why? |
When a subdomain is added to cPanel only as a dns record, instead of using subdomain feature, the client returns
|
@arnebjarne Hello, I am having an issue with the dns_cpanel script. It looks like it is not able to find my dns record even though it is there.
When I look at the _result variable around line 123 in dns_cpanel.sh, it looks like sometimes the script is getting the correct values and sometimes it is not. Any help is appreciated. |
@arnebjarne EDIT: |
Hiya All. have some problem with provider: reg[.]ru Fully debug outpud here: root@certbot:/home/crt# acme.sh --issue --force --dns dns_cpanel --dnssleep 300 --debug -d vcsa.mydomain.ru
|
See my post above. |
Do you use this command to extend an existing one? Because this method does not work for new ones. |
I used this for new ones too. |
I cobbled together some |
Thanks @benjaminrickels that script works well for me as I have multiple domains in my hosted Namecheap account and I wanted to add wildcard domains. However, there's another bug in deleting the acme TXT records in the domain - the _findentry function sed regex assumes the json data is in order (line, domain, txt value) but it quite often isn't. This can fail or even return the previous line number and attempt to delete the wrong record! So I wrote a replacement line which hopefully fixes it. _findentry Original: Replacement: Explanation: Search for the txtvalue and return data from the first start curly brace ("{"), cut the search result at the first end curly brace ("}") (as there might not be a lazy search option in sed), search for the "line": entry and return the numeric value. Hope that helps! BR |
Thanks @benjaminrickels and @TFX-Fahzan. That solved my issue. I had to modify @TFX-Fahzan's replacement tho as + doesn't work for me I changed it to *. Replacement: |
Had to change the zones-list parsing and the record-id parsing to be able to work with our cpanel installation. cPanel Version: 102.0 (build 16)
Please have a look at the diff: @@ -120,7 +120,7 @@
_get_root() {
_myget 'json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzones'
- _domains=$(echo "$_result" | sed 's/.*\(zones.*\[\).*/\1/' | cut -d':' -f2 | sed 's/"//g' | sed 's/{//g')
+ _domains=$(echo "$_result" | grep -oE '"[a-z0-9\.\-]*":\["; cPanel first' | cut -d':' -f1 | sed 's/"//g' | sed 's/{//g')
_debug "_result is: $_result"
_debug "_domains is: $_domains"
if [ -z "$_domains" ]; then
@@ -146,7 +146,7 @@
_debug "In _findentry"
#returns id of dns entry, if it exists
_myget "json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzone_records&domain=$_domain"
- _id=$(echo "$_result" | sed "s/.*\(line.*$fulldomain.*$txtvalue\).*/\1/" | cut -d ':' -f 2 | cut -d ',' -f 1)
+ _id=$(echo "$_result" | sed -e "s/},{/},\n{/g" | grep "$fulldomain" | grep "$txtvalue" | grep -oE 'line":[0-9]+' | cut -d ':' -f 2)
_debug "_result is: $_result"
_debug "fulldomain. is $fulldomain."
_debug "txtvalue is $txtvalue" |
Thanks, It worked like charm. Please push these changes |
Should be fixed in #4190 |
Not sure if this goes here or no, but once you've used this script to issue a wildcard certificate. how do you deploy it? The cpanel_uapi script filters out wildcard certificates. |
Hello and thank you for your work on this software. I can successfully install a letsencrypt cert on one subdomain, but my primary domain continues to display my outdated old cert--even after fully deleting it through cPanel. The new certificate appears in cPanel and seems to be installed correctly, but this is never reflected when trying to visit the site. When using the cpanel deploy hook, I receive two errors, seemingly related to regex. Despite these errors, the script reports a successful certificate installation... Log Snippet
|
I think I need to build in some error handling if I curl my cpanel host multiple times in a row it randomly do not get me all my dns zones like
I think i need to build in some checking if you request multiple domains and check if cpanel returns the domains. if not then try up to X times until all the zones are returned. Dont know if its the version 96.0.15 of cPanel which is buggy. |
Not sure if this is the area to post this but:
|
This is the place to report bugs in the cPanel DNS API.
If you experience a bug, please report it in this issue.
Thanks!
The text was updated successfully, but these errors were encountered: