WAT - Windows ACME Tool
wat.ps1 contains all the magic it needs to give you just what you want: free SSL/TLS Certificates for all your servers
In other terms it is a
You are good to go!
Make sure your system is up to date and has at least PowerShell 4 installed!
Get-Host
in a PowerShell Window.Windows6.1-KB2819745-x64-MultiPkg.msu
(on 64bit) or Windows6.1-KB2819745-x86-MultiPkg.msu
(on 32bit Windows)Note: it isn’t possible to export private keys of EC Certificates into Pem format on Windows 7 or Server 2012 R2
At this point I want to thank @lukas2511 for his fantastic work in dehydrated\
Without his inspirational masterpiece there would be no wat.ps1\
If you looking for a trustworthy slim acme client for linux/unix check out his works!
.\wat.ps1 [-Domains] <String[]> [-Email <String[]>] [-ResetRegistration] [-RenewRegistration] [-RenewCertificate] [-RecreateCertificate] [-RenewPrivateKey] [-OcspMustStaple] [-CA <Uri>] [-AcceptTerms] [-Staging] [-KeyAlgo [Rsa|ECDSA_P256|ECDSA_P384]] [-KeySize [2048|4096]] [-RenewDays <Int32>] [-ChallengeType [http-01|dns-01|tls-sni-01]] [-ACMEVersion [acme1-boulder|acme2-boulder|acme1]] [-BaseDir <DirectoryInfo>] [-CertDir <DirectoryInfo>] [-AccountDir <DirectoryInfo>] [-WellKnown <DirectoryInfo>] [-LockFile <FileInfo>] [-NoLock] [-ExportPassword <SecureString>] [-ExportPfx] [-ExportPkcs12] [-ExportCert] [-ExportPem] [-ExportPemCert] [-ExportPemKey] [-ExportIssuerPem] [-ExportPemEncoding [ASCII|UTF8|UTF32|Unicode|...]] [-onChallenge <ScriptBlock>] [-onChallengeCleanup <ScriptBlock>] [-NoDnsTest] [-InternalAccountIdentifier <String>] [-AccountKeyAlgo [Rsa|ECDSA_P256|ECDSA_P384]] [-AutoFix] [-Context {CurrentUser | LocalMachine}] [<CommonParameters>]
The script can take an array of domain names from piped input. Please have a look at the examples.
For detailed informations, just go ahead:
Get-Help .\wat.ps1 -Detailed
Get-Help .\wat.ps1 -Full
<String[]>
Specify a list of domain names.
The first is used as CommonName of your certificate.
Every domain name is added as SubjectAlternateName (SAN).
The Domains parameter can also be provided as piped input. Please be sure to define arrays of string arrays in this case.
<String[]>
E-mail addresses that are linked to the account
Accept CAs terms of service
Using the staging environment of Let’sEncrypt if -CA
isn’t specified
[CurrentUser|LocalMachine]
The place to save the certificate and keys
<DirectoryInfo>
Output directory for challenge-tokens to be served by webserver or deployed in -onChallenge
[http-01|dns-01|tls-sni-01]
Which challenge should be used? (default: http-01
)
Try to fix common problems automatically.\
This includes:
<ScriptBlock>
<ScriptBlock>
account.json
file)<Uri>
[Rsa|ECDSA_P256|ECDSA_P384]
[Rsa|ECDSA_P256|ECDSA_P384]
[2048|4096]
4096
)\<Int32>
30
)[acme1-boulder|acme2-boulder|acme1]
<DirectoryInfo>
<DirectoryInfo>
<DirectoryInfo>
<FileInfo>
<SecureString>
-ExportPfx
and -ExportPkcs12
)-ExportPassword
)-ExportPassword
).crt
public certificate file (Only public certificate without private key)[ASCII|UTF8|UTF32|Unicode|...]
<String>
.\wat.ps1 example.com
Basic usage for issuing a certificate for domain example.com
.\wat.ps1 example.com -ContactEmail me@example.com
Updating the registration with given email address
.\wat.ps1 -Domain "example.com" -WellKnown D:\htdocs\.well-known\acme-challenge
Placing the verification tokens in the specified directory
.\wat.ps1 -Domain ("example.com", "www.example.com") -Staging
Including example.com
and www.example.com
in the SubjectAlternateName attribute of the certificate\
Using the Let’sEncrypt staging environment for testing purpose
$certs = (("example.com", "www.example.com"), ("jon.doe.xy")) | .\wat.ps1
Working a set of 2 certificates.\
Certificate 1:\
Name: example.com
\
Domains: example.com
, www.example.com
\
Certificate 2:\
Name: jon.doe.xy
\
Domains: jon.doe.xy
C:\Scripts\wat\wat.ps1 -Domains "example.com" -WellKnown C:\inetpub\well-known\acme-challenge -AcceptTerms -AutoFix -Context LocalMachine
This is my entire config (as scheduled task) to update the SMTP Certificate in one of my ExchangeServers.\
After the initial set up and binding of the Certificat to the SMTP service (e.g. in the ECP GUI), I don’t have to update any ExchangeServer configuration every time the certificate is renewed.\
That’s what I call In-Place-Renewal - I didn’t find anything on the web to this mechanism.
.\wat.ps1 -Domains "example.com" -ChallengeType tls-sni-01 -Context LocalMachine -Staging -onChallenge {
Param([String] $Domain, [String] $FQDN, [Security.Cryptography.X509Certificates.X509Certificate2] $Cert)
Import-Module WebAdministration -ErrorAction SilentlyContinue
if (!(Get-Module WebAdministration) ) { throw "Couldn't load WebAdministration module" }
# Remove old entries
Get-WebBinding -Protocol https -Port 443 -HostHeader $FQDN -IPAddress '*' | Remove-WebBinding
Get-Item "IIS:\SslBindings\*!443!$($FQDN)" -ErrorAction SilentlyContinue | Remove-Item
# Create new bindings
New-WebBinding -IPAddress "*" -Port 443 -HostHeader $FQDN -Protocol https -SslFlags 1 -Name "Default Web Site"
New-Item "IIS:\SslBindings\*!443!$($FQDN)" -Thumbprint $($Cert.Thumbprint) -SSLFlags 1 | Out-Null
} -onChallengeCleanup {
Param([String] $Domain, [String] $FQDN, [Security.Cryptography.X509Certificates.X509Certificate2] $Cert)
# Remove bindings
Get-WebBinding -Protocol https -Port 443 -HostHeader $FQDN -IPAddress '*' | Remove-WebBinding
Get-Item "IIS:\SslBindings\*!443!$($FQDN)" -ErrorAction SilentlyContinue | Remove-Item
}
This is a working implementation of tls-sni-01 challenges in IIS. You may have to change it to match the name of your default web site.
As in the example above, you have to set up a binding of the new Certificat in the IIS GUI.