From 16b2e6ce9614c2b9c58715c1e7cfa322f8dea9ba Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 27 Oct 2023 22:26:53 +1100 Subject: [PATCH] feat: Added new and renew powershell scripts --- .gitignore | 2 ++ new.ps1 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ renew.ps1 | 1 + 3 files changed, 49 insertions(+) create mode 100644 .gitignore create mode 100644 new.ps1 create mode 100644 renew.ps1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d00e7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +acme-dns.json diff --git a/new.ps1 b/new.ps1 new file mode 100644 index 0000000..a139a77 --- /dev/null +++ b/new.ps1 @@ -0,0 +1,46 @@ +# Install Certify The Web (if not already installed) +#> Install-Module -Name Posh-ACME + +$domain = 'example.com' +# Will do wildcard for *.$domain in addition to root + +# Make an HTTP POST request +$response = Invoke-RestMethod -Uri "https://auth.acme-dns.io/register" -Method Post + + +# Print Instructions +Write-Host "Please add the following CNAME to your DNS:" +Write-Host "Host: _acme-challenge" +Write-Host "Target: " +$response.fulldomain + +# Save response to use later +$response | ConvertTo-Json | Out-File -FilePath .\acme-dns.json + + +# Wait for DNS to update +Write-Host "Press any key after adding record..." +$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') + + +# Read file back in (if you closed the shell) +# $response = Get-Content -Raw -Path .\acme-dns.json | ConvertFrom-Json + + +$reg = @{ + "_acme-challenge.$domain" = @( + # the array order of these values is important + $response.subdomain + $response.username + $response.password + $response.fulldomain + ) +} + +$pArgs = @{ + ACMEServer = 'auth.acme-dns.io' + ACMERegistration = $reg +} + +$domains = '*.'+$domain,$domain +New-PACertificate $domains -Plugin AcmeDns -PluginArgs $pArgs -Verbose \ No newline at end of file diff --git a/renew.ps1 b/renew.ps1 new file mode 100644 index 0000000..5144708 --- /dev/null +++ b/renew.ps1 @@ -0,0 +1 @@ +Submit-Renewal -AllAccounts \ No newline at end of file