Submitted by george.asenov on Mon, 03/07/2016 - 10:06
Hello,
Appears that virtualmin do not have API for Let's encrypt SSL certificates. So we are unable to issue/install Let's Encrypt certificate trough the virtualmin API. Can you please add API functions to virtualmin for managing Let's Encrypt certificates for virtualmin domains.
Status:
Closed (fixed)
Comments
Submitted by pcfreak30 on Mon, 03/07/2016 - 14:48 Comment #1
I was about to ask this too. Would like to see options on CLI to mass setup letsencrypt.
Submitted by JamieCameron on Mon, 03/07/2016 - 18:15 Comment #2
Good suggestion ... I will look into adding this.
Submitted by JamieCameron on Sat, 03/12/2016 - 17:39 Comment #3
This has been implemented, for inclusion in the 5.02 Virtualmin release.
Submitted by JamieCameron on Sat, 03/12/2016 - 17:40 Comment #4
Submitted by george.asenov on Mon, 03/21/2016 - 10:46 Comment #5
Thank a lot Jamie! We already implemented this feature in our panel, so we can start using it a soon as it is available in Virtualmin.
If you are OK you might send the API command (I believe it is just one .pl file) to us (maybe here as attachment) and we will test is thoroughly and give feedback before the official 5.02 release?
Thanks again for all the great code!!!
Submitted by JamieCameron on Mon, 03/21/2016 - 22:37 Comment #6
Ok, I have attached the script to this ticket.
Submitted by pcfreak30 on Tue, 03/22/2016 - 02:11 Comment #7
Please put an all-domains switch. Don't want to have to make a for loop from list-domains command.
Submitted by george.asenov on Tue, 03/22/2016 - 03:09 Comment #8
Thanks a lot Jamie!
I did installed it. I will test it now and give feedback ASAP.
Submitted by pcfreak30 on Tue, 03/22/2016 - 08:51 Comment #9
Does this also setup auto-renew?
Submitted by pcfreak30 on Tue, 03/22/2016 - 09:17 Comment #10
Submitted by george.asenov on Tue, 03/22/2016 - 09:45 Comment #11
It all works as expected I tested it in all combinations. There is a funky error message if you try a wildcard certificate (I guess the standard domain validation is used), but that is fine as wildcard certificates are not allowed at the moment with Let's encrypt.
The API does not include the autorenew parameter, but I will add it and post the updated file here.
pcfreak30, posting huge error without any details on how did you get this is not a good idea...
Update:
If you try to create a Let's encrypt certificate over existing one, there is an error (this is not API related, probably in the main webmin lib):
Expected full certificate file /letsencrypt/live/domain.com-0001/fullchain.pem was not found
domain.com is the domain and with each new try 0001 increments.
I will try to find this one too and report it back
Submitted by pcfreak30 on Tue, 03/22/2016 - 09:54 Comment #12
for i in $(virtualmin list-domains --name-only); do virtualmin generate-letsencrypt-cert --domain $i; done
Submitted by JamieCameron on Tue, 03/22/2016 - 21:27 Comment #13
pcfreak30 - that huge warning is basically harmless, and will be fixed in the next Webmin release.
Submitted by george.asenov on Wed, 03/23/2016 - 11:55 Comment #14
I added --renew parameter to the API. If you find it OK you might add it to the release.
Here is the diff only:
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- a/generate-letsencrypt-cert.pl
+++ b/generate-letsencrypt-cert
@@ -7,7 +7,8 @@
The server must be specified with the C<--domain> flag, followed by a domain
name. By default the certificate will be the for domain name only, but you
can specify an alternate list of hostnames with the C<--host> flag, which
-can be given multiple times.
+can be given multiple times. Additional C<--renew> flag can be used for months
+between auto renewal.
=cut
@@ -38,6 +39,9 @@
elsif ($a eq "--host") {
push(@dnames, lc(shift(@ARGV)));
}
+ elsif ($a eq "--renew") {
+ $renew = shift(@ARGV);
+ }
elsif ($a eq "--multiline") {
$multiline = 1;
}
@@ -64,6 +68,7 @@
&usage($err) if ($err);
}
}
+!$renew || $renew =~ /^[1-9][0-9]*$/ || &usage("Invalid --renew parameter");
# Request the cert
&foreign_require("webmin");
@@ -85,6 +90,12 @@
# Save renewal state
$d->{'letsencrypt_dname'} = $custom_dname;
+ if (!$renew) {
+ delete($d->{'letsencrypt_renew'});
+ }
+ else {
+ $d->{'letsencrypt_renew'} = $renew;
+ }
$d->{'letsencrypt_last'} = time();
&save_domain($d);
@@ -124,6 +135,7 @@
print "\n";
print "virtualmin generate-letsencrypt-cert --domain name\n";
print " [--host hostname]*\n";
+print " [--renew months]\n";
exit(1);
}
Submitted by george.asenov on Wed, 03/23/2016 - 11:58 Comment #15
Here is the updated API with the --renew added