-
Notifications
You must be signed in to change notification settings - Fork 184
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
Automating manual handler #76
Comments
Yes. Assuming you issue an update request and capture the response you can process it in PowerShell. Suppose you issue an update request like this ('dns1' was the alias used in the New-ACMEIdentifier command) :
Then you can process $result to extract the url and content for the file that needs to be created:
|
[Update 2017-01-02] The script is now available as in a GitHub repository @whereisaaron is creating a variant to add support for the dns-01 method for AWS Route 53 users. Here's a script to create/renew certificates. You can watch a video about using ACMESharp and the script on YouTube. [Update 2016-09-21] Added two more suggestions by @hahndorf: 1) Improved the friendly name generated to include the expiry date and that it is an LE certificate; 2) added an option that allows the deletion of old certificates to be optional. The new option is called 'keepOldCertificates' which is $false by default to retain backwards compatibility. [Update 2016-09-20] Made some modifications suggested by @hahndorf below. Thanks, Peter. [Update 2016-02-06] The script has been modified to:
[Update 2016-02-21] Fixed a small bug line 412 where 'true' is used instead of '$true' This script may help some people use ACMESharp. I need something like this right now so it has been necessary to put something together. It performs the steps documented on the getting started page and adds error trapping/reporting. It then goes on to remove a certificate from the certificate store if it exists, adds the new one and set a friendly name. Here is an example command to create a certificate for a single domain:
This command will create a certificate for more than one domain and add the organization option to the CSR:
WARNING: Binding host name 'www.xxx.com' is not equals to certificate subject name 'www.yyyy.com'. Client may not be able to connect to the site using HTTPS protocol
"www-mydomain$suffix"
|
Thanks @bseddon, I'll check it out and put it up in a contributions section for others to get at. |
Would you be OK if I created a video to go with it? I don't want to get in the way of your plan or hog the limelight but equally, you've created a great tool and showing people how easy it can be to create and regenerate certificates on the Windows platform may help some get into ACMESharp. The downside is that the script does not use the DNS option so requires access to the web site root folder. On the other hand, supporting the ability to automatically add a TXT record into any DNS server is no practical. I tried yesterday to support GoDaddy and EasySpace in addition to Route53 and gave up. |
Hey @bseddon, I just tried your script and it's great. I had to modify some small parts, because that windows server is running apache and I need no import to the windows cert store. The script really simplifies the task of obtaining a certificate on windows. But as far as I understand that the script cannot be used to automatically renew a expiring certificate. I'm still dreaming of a set-and-forget script that can just be put into the task scheduler for example. Do you think that's possible? Thank you - both of you - for the great work! |
@seteq You need to run it again with a different alias. You might call the script's function in a one line script of your own and set the alias to be 'mydomain' + somedatestring. As long as the alias is unique each time the script is run a new certificate will be requested and loaded into the certificate store replacing the one already their with the same common name (CN) field. Of course in your case you will be saving the certificate in some location referenced by httpd.conf (or a file it imports). Maybe Eugene will comment on whether the 'reset' flag on Complete_ACMEIdentifier can be used to reuse an existing alias. I've not been motivated to play with the options because it works OK for me at the moment. PS No credit to me. The kudos goes to @ebekker for the great implementation and especially the PowerShell support. |
@bseddon, I think my plans for world domination are safe, go forth and create your video, take as much limelight as you want, enjoy! When you have it ready, let me know, I'll update the contributions page to include the link to it as well, thanks. It's true the DNS option is tricky because there is no standard for DNS management, so individual hosting providers will need their own providers in ACMESharp to be supported. Having said that, if you want to support a DNS hosting service natively, it needs to expose an API to support true automation, and the two that you mention don't seem to offer that unless you use their reseller services. I think that is by design based on their sales model. However, there are many other hosting providers that do offer APIs and I plan to either add them myself or support others to contribute (Azure, Google DNS, EasyDNS just to name a few). I started with AWS R53 just because that's a service that I have plenty of past experience with and just needed something to prove out the model with. I think the DNS challenge type is quite important for ACME and LE in general because it's the only way for an org to secure an internal (non-public) HTTPS interface. And of course, even if there is no automated support for it, there is always the manual provider which just gives you the RR records that need to be created. |
@ebekker Yesterday I added a link to my comment further up this thread which points to a video about using your PowerShell commands to automate the generation of LE certificates. However, I forgot that you don't see my edits so this is a note to fix that. |
@bseddon Any chanse you could add support for -AlternativeIdentifierRefs? |
@Petoj87 Good point. I'll take a look at that. Certificate details as well (Country, StateOrProvince, Description, etc.) |
@Petoj87 I've added support for alternative identifiers so one certificate is able to support multiple domains. There's a Let's Encrypt imposed limit of 5 certificate requests each 7 days at least for the public beta. Because of this limitation a certificate can only include 5 requests for the same domain. |
I started to write something similar to this, then bam! not only does it exist, its far more in depth than I intended. Thanks. |
I had the same question about how we can automate the DNS challenge. I was hoping the name of the resource record to create and the value would be part of the PowerShell object returned but I can't see that. It seems this information is only returned to the host which I cannot understand. Why return an object but not include this information in it? I have tried the following code modified from the example above:
But both parts come back as null. I assume this is because these properties are only valid in the http challenge. Simply put, how do I get the DNS resource record name and the value into an object in PowerShell? Thanks |
I just started using your automated script, and I typed the following and it says |
Yes, it will unless you own 'www.mydomain.com' on an IIS site definition you have named 'domain.com' These parameters need to be your web site and the name of the web site definition in your instance of IIS. |
I'm little confused, ok so my IIS under sites, i have a site called ninjablume.com and i added https://ninjablume.com to bind it, which it tells me too. Question
I'm still getting that same message. |
Your new command looks good except you can't reuse the alias. In your last email you said the alias 'dns-07192016' was invalid. If you try to reuse it you are telling the script to use an invalid alias which will always fail. Just make up a new name. |
i actually did that, but i changed it to like dns10-2016 and it still failed I end up creating fake test.com. and it still does the same thing. test.com bad example |
You need to do more than claim it has failed. The script executes 8 or more ACMESharp commands and the failure could be anywhere. There will be a lot of output as the script runs. Why not post it here otherwise I'm just guessing. Have you used the -CheckParameters option so the script will check you are providing valid parameters? |
I don't understand your question. I don't understand what is asking you to bind HTTPS to the domain? Can you cut-and-paste the message or include a screenshot? |
Check that the domains for which certificates are to be generated have an https binding in the web site
|
You can't reuse aliases. An alias represents information held on the Let's Encrypt server. A copy of this information is held in the vault. I think @ebekker has created a topic here to review this constraint so that we can remove the information and the alias from the vault. But until then its necessary to create a new identifier (alias) for each new certificate. |
Good point about the binding check. |
Let me rephrase this so we don't get confused. First, the automation works, which is great, thanks. so i came conclusion that it is not really necessary to create a new -alias when you renew the certificate, So what i did was i found a certifcate earlier and found out the -alias and i just update that one instead using the same format Update-Certificate-Http -alias "dns3-07152016" -domain "ninjablume.com" -websiteName "ninjablume.com" it renew the certification. |
No, it will not renew the certificate. When ACMESharp first generates a certificate it is stored in the vault. When you re-run the script with the same alias, it finds the alias in the vault then finds the previously generated certificate and re-applies it to IIS. Let's Encrypt certificates last just 90 days. So you will need to re-run the script with a different alias so a new certificate is generated and applied to your site. |
really because i just did that and it renewed, see the following. |
I think you have used the alias dns1-07162016 (which is shown in the .txt file) to complete the challenge but you had not generated a certificate for this alias. You can see in the output that the alias was found but certificate had not yet been generated for that alias. If you re-run the command now using the same alias (dns1-07162016) I think you will see the output is different. Instead of text stating that it is creating a new certificate the output will include a line something like: "A certificate for 'certdns1-07162016' already exists with id xxx" |
is so weird ok so i did exactly the same as you referring to the alias needs to be change right so here's my output. but why would it be invalid. |
Issue the command: Get-ACMEIdentifier eagl4000-07192016 The output will show a 'uri' value. This is a link to a page on the Let's Encrypt servers which contains challenge status and other information. It will contain information you may be able to use to find out why this identifier could not be validated. |
would CloufFlare be causing this, because I'm using cloudflare.. |
Maybe. Based on the information in the file 'eagle4000-new with new alias.txt' I would expect to see the challenge token in a file referenced by this url but there is nothing there: http://www.eagle4000.com/.well-known/acme-challenge/5M-gTpufumFt8_IJC54Mm2EDGcwzE8Pj5Qy7QNjse3c |
Let me do some testing then, I'll let you know so if people actually using cloudlfare then its an issue. I know the codes and the automation works because I tested them manually. all you did was just added scripts and automate everything so im going to assume it could be a cloudflare issue that doesn't like it. I totally appreciate your patience with me with all these nonsense stuff but its a learning process.. |
if i don't have a certificate install for a specific domain, the automation will keep asking me to add https binding in IIS before using these domains. is there a way for me to bypass this. |
Just use the certificate of another site to create the initial binding. It doesn't matter that the certificate is not valid for the site because it will be replaced as soon as the script is run. |
Thanks, it still doesn't work. after it try to create a new certification all the sudden it gives me permission denied. I think i have no luck with this automated script. thanks anyways i'll just do it manually for now. |
i finally got it to work @bseddon there was a conflict where i was using a built in control panel that supports Let's Encrypt, but since if i want to use this automation. then i cannot use the builtin control panel version of ACMESharp. ;) |
I like to propose two changes to Update-Certificate-http.ps1, but it seems that file is not part or any repository?
even though I specified the
On line 215:
My physicalPath looks like
|
HI Peter Thanks for the suggestions. I've updated the zip file in the comment above to include your suggestions. If you get a chance to look at the update to make sure I've applied them correctly it will be great. Regards Bill Seddon |
Hey Bill, yes, that worked fine, I just started using LetsEncrypt and manage a server with just 15 certificates, but it seems to work fine. I made two more changes to your script: I don't delete old certificates straight away, I like to keep them as a backup, just in case something is wrong with the new one. A different clean-up script deletes them later. Rather than just using the hostname for the friendly name, I added the expiry date of the certificate, this way I can see in IIS when they expire (around line 606).
also adding an "LE" for lets encrypt, because I still use other CAs. These changes should be configurable via parameter. Not essential, but that's how I like it, thanks for your work. |
Thanks again for your suggestions. I've implemented both and updated the file. Generating a more informative friendly name seems like a good idea as does making the viewer aware of the source of the certificate. I take you point that the deletion of old certificates should be optional. I learned something new along the way: the existence of the 'notAfter' property. Regards Bill |
Thanks Bill, I wrote a short blog post about my experience with ACMESharp. I now use ACMESharp, your script and my own meta script to automatically update all Let's Encrypt certificates on my server that are about to expire. It needs more testing, but I now have a fully automated solution to update/renew all certificates. |
Nice, thanks for letting me know. I have another potential topic for you to include. You probably don't see it because you only used https before you started using ACMESharp. Imagine you are new to SSL and choosing to use ACMESharp for the first time so there are only http sites. In this case the script will fail in the pre-check complaining there is no existing https binding. It's complaining because it's not going to add an https binding only update/replace the certificate associated with an exising https binding. The solution is to add an https binding using the IIS manager and associate any certificate with that binding. It doesn't matter that the certificate is not valid for the domain it just needs to fool IIS into adding the binding. As soon as the script is run the invalid certificate will be replaced and life is good once again. Bill |
Thanks for the write up, I've added your blog post to the contributions page. |
I have completed the update to @bseddon's script for ACMESharp to also support other types of automated ACME challenges, not just You just need an AWS IAM key/secret and the AWS Route 53 'Hosted Zone Id' for the public DNS domain. Your IIS website can be private, or password-protected, or HTTPS only and this method will still works.
It even works to issue a certificate if you don't have IIS running at all, e.g. for another web server or service.
|
Manual Challenge Handler has been updated with a new |
Hi,
I need to automate the certificate creation/renewal on a windows server with a special/unknown web server.
Is there a possibility to automate the manual method of Complete-ACMEChallenge?
Can the information about the file (url/content) be redirected to a powershell variable or is there a way to create that file directly?
Thank you!
The text was updated successfully, but these errors were encountered: