Skip to content
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

Can't extract DNS values from first part #93

Open
He-Man321 opened this issue Jun 26, 2024 · 3 comments
Open

Can't extract DNS values from first part #93

He-Man321 opened this issue Jun 26, 2024 · 3 comments

Comments

@He-Man321
Copy link

I have created a PS script to create the certificates, update the DNS (through the GoDaddy API) and import the PFX file to IIS, and although I still have a few things to tidy I can see how it can all work...

...Except, how do you get the DNS TXT values from the first command into variables?

Essentially, when you run the first part (with the --delayed argument) it outputs several (one for each sub domain specified) keys that need to be put in to the DNS TXT records. I can copy and paste these in to the following commands that set them using the GoDaddy API, but how can I have them output in to variables so I can automate this?

There is nothing in the documentation, but without this I don't see how I can automate the whole thing?

Thanks.

@JustinWebDev
Copy link

What is the 'first command' and the 'following commands'?

I tried to do the same thing and had to abandon it. I had trouble with getting GoDaddy's API to work but also had the same issue you are asking with the DNS TXT values. The only way I could see it work was output a log from LE then find the value in the log file. I was chasing Log::Log4perl stuff. Gave me a headache. I was so close, too.

I hope the developer can supply a more straight-forward way.

@He-Man321
Copy link
Author

If you had trouble with the GoDaddy DNS, the below is what I did to get it working, in case that helps:

So run this to start the process:
./le64.exe -email "[email protected]" -key domain.key -csr domain.csr -csr-key domain.key -crt domain.crt -domains "domain.co.uk,www.domain.co.uk" -generate-missing -live --handle-as dns --export-pfx "PASSWORD" --tag-pfx "domain.co.uk" --delayed

then this to create the DNS entries (note the "OUTPUT FROM ABOVE HERE" bit, which is the bit I want to automate:
Invoke-RestMethod -Method PUT -Uri "https://api.godaddy.com/v1/domains/domain.co.uk/records/TXT/_acme-challenge" -Headers @{ Authorization="sso-key GODADDYKEY:GODADDYSECRET"} -ContentType "application/json" -Body "[{"data": "OUTPUT FROM ABOVE HERE","ttl": 600}]";
Invoke-RestMethod -Method PUT -Uri "https://api.godaddy.com/v1/domains/domain.co.uk/records/TXT/_acme-challenge.www" -Headers @{ Authorization="sso-key GODADDYKEY:GODADDYSECRET"} -ContentType "application/json" -Body "[{"data": "OUTPUT FROM ABOVE HERE","ttl": 600}]";

then this to complete the certificate generation:
./le64.exe -email "[email protected]" -key domain.key -csr domain.csr -csr-key domain.key -crt domain.crt -domains "domain.co.uk,www.domain.co.uk" -generate-missing -live --handle-as dns --export-pfx "PASSWORD" --tag-pfx "domain.co.uk"

And finally, to clear up the DNS entries afterwards:
Invoke-RestMethod -Method DELETE -Uri "https://api.godaddy.com/v1/domains/domain.co.uk/records/TXT/_acme-challenge" -Headers @{ Authorization="sso-key GODADDYKEY:GODADDYSECRET"}
Invoke-RestMethod -Method DELETE -Uri "https://api.godaddy.com/v1/domains/domain.co.uk/records/TXT/_acme-challenge.www" -Headers @{ Authorization="sso-key GODADDYKEY:GODADDYSECRET"}

I then imported the certificate to IIS with this:
$thumb=(Import-PfxCertificate -FilePath "domain.pfx" -CertStoreLocation "Cert:\LocalMachine\WebHosting" -Password (ConvertTo-SecureString -String "PASSWORD" -AsPlainText -Force)).Thumbprint

Which gave me the thumbprint to the add it to the bindings, which I didn't quite finish, because I didn't see the point unless I could automate that earlier step...

@JustinWebDev
Copy link

Thanks much for that info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants