0

I'm working on a website where users can add a domain name to their project. By doing this the domain is added as domainpointer to my Direct Admin account. I do this using the Direct Admin Api.

This all works great but this new domain is not added to the SSL certificate automatically. And I have to click the renew button by hand to make this happen.

I want to do this renewal programmatically but I'm stuck. I first tried adding a new SSL certificate like this:

$sock->query('/CMD_API_SSL',
  array(
    'domain' => $domain,
    'action' => 'save',
    'type' => 'create',
    'request' => 'letsencrypt',
    'name' => $domain,
    'keysize' => 'secp384r1',
    'encryption' => 'SHA256',
    'le_select0' => $domain,
    'le_select1' => 'www.' . $domain,
    'submit' => 'save'
  ));

$result = $sock->fetch_body();
}

But this doesn't seem the right way, looking at the renew button in Direct Admin I saw that there is a Let's Encrypt Plugin used for renewing the SSL certificate.

I tried to call this by doing:

  $sock->set_method('POST');

  $sock->query('/CMD_PLUGINS/letsencrypt/renew.html',
    array(
      'domain' => $domain,
    ));

But this doesn't work either, the SSL certificate is not renewed. As result I get a page saying 'I cant find an e-mailadress, contact support'.

Does anyone know how I can get this to work? Thanks in advance.

Zebda
  • 299
  • 3
  • 10
  • What Directadmin version are you using ? There is a feature called AUTOSSL that will take care the renewal. – Kalib Zen Jan 11 '22 at 15:42
  • You also can trigger the script using Directadmin hookscript called dns_write_post.sh. So when a DNS record is written, it will automatically call another script to renew your domain. – Kalib Zen Jan 11 '22 at 15:44
  • Hi Kalib, thanks for your reply this new function AUTOSSL is not enabled yet and I can't add hookscript because I'm on shared hosting. I'm not able to change Direct Admin settings. I need to get this working using the Direct Admin Api. Do you have any suggestions for this? – Zebda Jan 12 '22 at 23:56
  • So, I re-read your questions. The main issue was with the subdomain renewal using API. I understand this issue but there is one problem that I don't think you can provide here: `The API debug log`. The problem is only an admin can view this log and understand what is going on behind the code. My suggestion is to become an admin of Directadmin and becoming an Admin is very cheap compared to Cpanel. There is not much you can do with limited access to the Directadmin features. You can ask your provider to provide a log file but enabling debug mode will turn off the entire server for a few seconds – MaXi32 Jan 14 '22 at 15:59
  • If you can provide the API debug log, you will know what errors you will get when triggering the API. Try to discuss with your provider to obtain the log (if they are willing to do so). This is what they should enable: https://www.directadmin.com/features.php?id=930 – MaXi32 Jan 14 '22 at 16:04

0 Answers0