Free ACME scripts / Windows
RDS
Installs a simple-acme certificate on every Remote Desktop Services role on this server: RD Gateway, the RDP listener, RD Publishing, RD Web Access, RD Redirector, the RD Web Client and the RD Connection Broker deployment.
- Version
- 1.2
- Language
- PowerShell
- SHA-256
- ffce353ffe1d78efa428611c700888503e865745203a5f1b9168060cfde27be7
- Licence
- Apache-2.0, copyright FairSSL A/S
Download it on the server, check the SHA-256 and keep it as C:\simple-acme\Scripts\ImportRDSFullFairSSL.ps1, so a newer version later replaces it without a change to your renewal:
# Windows PowerShell 5.1 needs TLS 1.2 switched on for this session
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -UseBasicParsing -Uri 'https://sslbrain.com/scripts/files/rds-1.2.ps1' -OutFile 'C:\simple-acme\Scripts\ImportRDSFullFairSSL.ps1'
(Get-FileHash 'C:\simple-acme\Scripts\ImportRDSFullFairSSL.ps1' -Algorithm SHA256).Hash -eq 'FFCE353FFE1D78EFA428611C700888503E865745203A5F1B9168060CFDE27BE7'
Unblock-File 'C:\simple-acme\Scripts\ImportRDSFullFairSSL.ps1' What it does
FairSSL edition of ImportRDSFull.ps1 from win-acme (Apache License 2.0, https://github.com/win-acme/win-acme, dist/Scripts/ImportRDSFull.ps1). The sequence of RDS calls is the same. What changed, and why:
- Runs on Windows Server 2012 (PowerShell 3) and 2012 R2 (PowerShell 4). The original used New-TemporaryFile, which first exists in PowerShell 5, so on 2012/2012 R2 it set RD Gateway and the RDP listener and then stopped before the RDS deployment roles. The temporary PFX is now created with [System.IO.Path]::GetTempFileName().
- Fails with a non-zero exit code. The original ended every error branch with "return", which exits 0, so simple-acme and the FairSSL renewal notification reported a half-done installation as a success.
- The temporary PFX, which holds the private key, is deleted on every path. The original deleted it only when the last step was reached.
- A standalone RD Gateway without an RD Connection Broker is updated and reported as a success. The original failed on the deployment roles there and, because it exited 0, looked green anyway.
- The PFX password comes from the cryptographic RNG instead of System.Web.Security.Membership.
- A server without RD Gateway (no TSGateway service) is updated too. The original stopped at the RD Gateway listener there and never reached the RDP listener or the deployment roles. The deployment's RD Gateway certificate is set only when the deployment has an RD Gateway server.
Parameters are positional and identical to the original, so an existing renewal can switch by changing only the script name.
Exit codes: 0 every role on this server and in its deployment updated; without an RD Connection Broker here, the RDP listener (and RD Gateway, when it is installed) updated 1 a certificate role could not be set (the output names which) 2 the certificate is not in LocalMachine\My 3 the private key could not be exported (PrivateKeyExportable is off) 4 the Remote Desktop Services module or the remote broker session failed 7 PowerShell older than 3.0
Requirements
- Windows Server with Windows PowerShell 5.1, run as Administrator
- simple-acme, which runs the script after each issuance and renewal
Parameters
| -NewCertThumbprint | Thumbprint of the new certificate. simple-acme passes it as {CertThumbprint}. |
|---|---|
| -RDCB | FQDN of the RD Connection Broker. Default: this computer. |
| -OldCertThumbprint | Thumbprint of the replaced certificate. When the broker is a remote machine, the old certificate is removed from its Personal store after a successful update. |
Get a certificate and run the script
Run simple-acme's
wacs.exe from its folder (here C:\simple-acme) as Administrator. It orders the
certificate, saves it in the Windows certificate store and as PEM files, runs the script, and creates the scheduled task that
renews the certificate and runs the script again. Replace www.example.com, the e-mail address and
the script's parameters (see Parameters; simple-acme fills in tokens such as
{CertThumbprint}, {StorePath} and {RenewalId}).
--validation selfhosting answers the CA's HTTP challenge on port 80; on a web server use
--validation filesystem --webroot <site folder> instead.
Let's Encrypt
Directory: https://acme-v02.api.letsencrypt.org/directory. No account to create: the client registers one with your e-mail address. Let's Encrypt documentation
.\wacs.exe `
--baseuri "https://acme-v02.api.letsencrypt.org/directory" `
--accepttos --emailaddress "you@example.com" `
--source manual --host "www.example.com" `
--validation selfhosting `
--store certificatestore,pemfiles --pemfilespath "C:\simple-acme\Certificates" `
--installation script `
--script ".\Scripts\ImportRDSFullFairSSL.ps1" `
--scriptparameters "<parameters>" Google Trust Services
Directory: https://dv.acme-v02.api.pki.goog/directory. Create an EAB key in a Google Cloud project (gcloud publicca external-account-keys create). Put the key's id and HMAC in place of EAB_KID and EAB_HMAC. Google Public CA tutorial
.\wacs.exe `
--baseuri "https://dv.acme-v02.api.pki.goog/directory" `
--eab-key-identifier "EAB_KID" --eab-key "EAB_HMAC" `
--accepttos --emailaddress "you@example.com" `
--source manual --host "www.example.com" `
--validation selfhosting `
--store certificatestore,pemfiles --pemfilespath "C:\simple-acme\Certificates" `
--installation script `
--script ".\Scripts\ImportRDSFullFairSSL.ps1" `
--scriptparameters "<parameters>" ZeroSSL
Directory: https://acme.zerossl.com/v2/DV90. Copy the EAB credentials from the Developer section of your ZeroSSL account. Put the key's id and HMAC in place of EAB_KID and EAB_HMAC. ZeroSSL ACME documentation
.\wacs.exe `
--baseuri "https://acme.zerossl.com/v2/DV90" `
--eab-key-identifier "EAB_KID" --eab-key "EAB_HMAC" `
--accepttos --emailaddress "you@example.com" `
--source manual --host "www.example.com" `
--validation selfhosting `
--store certificatestore,pemfiles --pemfilespath "C:\simple-acme\Certificates" `
--installation script `
--script ".\Scripts\ImportRDSFullFairSSL.ps1" `
--scriptparameters "<parameters>" acme.sslbrain.com
Directory: https://acme.sslbrain.com/acme/directory. Create an EAB key in sslbrain Cloud (Basic or higher) under ACME clients, Connect a client. sslbrain Cloud validates the domain through a CNAME redirect, a DNS API or pre-validation, not your ACME client. Put the key's id and HMAC in place of EAB_KID and EAB_HMAC. sslbrain plans
.\wacs.exe `
--baseuri "https://acme.sslbrain.com/acme/directory" `
--eab-key-identifier "EAB_KID" --eab-key "EAB_HMAC" `
--accepttos --emailaddress "you@example.com" `
--source manual --host "www.example.com" `
--validation none `
--store certificatestore,pemfiles --pemfilespath "C:\simple-acme\Certificates" `
--installation script `
--script ".\Scripts\ImportRDSFullFairSSL.ps1" `
--scriptparameters "<parameters>" Licence and credits
Copyright FairSSL A/S, licensed under the Apache License 2.0: use it, change it and share it, also commercially.
Based on a script from simple-acme (formerly win-acme), Apache-2.0. Thanks to the simple-acme project.
One script per server, or sslbrain does it for all your servers without scripts.
Feedback and improvements are welcome: info@fairssl.dk