Free ACME scripts / Windows
NetScaler
Installs a simple-acme PEM certificate on Citrix NetScaler / ADC.
- Version
- 1.1
- Language
- PowerShell
- SHA-256
- d2ed7ecc51026b84c0a99869a39b593b08eecfb504657aa5abdebe11c3a2281e
- 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\Install-NetScalerCert.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/netscaler-1.1.ps1' -OutFile 'C:\simple-acme\Scripts\Install-NetScalerCert.ps1'
(Get-FileHash 'C:\simple-acme\Scripts\Install-NetScalerCert.ps1' -Algorithm SHA256).Hash -eq 'D2ED7ECC51026B84C0A99869A39B593B08EECFB504657AA5ABDEBE11C3A2281E'
Unblock-File 'C:\simple-acme\Scripts\Install-NetScalerCert.ps1' What it does
Reads PEM files created by simple-acme and deploys them through the NITRO API: it uploads the certificate and key files, creates or updates the SSL cert-key or cert-key bundle, binds it to the SSL vServers or the global VPN binding, and saves the NetScaler configuration.
In Auto mode (the default) the script reads the NetScaler version and uses SSL cert-key bundle on ADC builds from 14.1 build 21.x, when no classic cert-key with the name in -certName exists already, so intermediate changes are handled by the native bundle update path. Older appliances use classic SSL cert-key. A global VPN binding always uses classic cert-key, because a cert-key bundle binds to SSL vServers only.
The script uses HTTPS for NITRO and accepts any management certificate, including a self-signed one, unless -ValidateManagementCertificate is given. With -UseHttp the login and the private key are sent unencrypted.
After a run the script prints a command that runs it again with the same parameters and the same PEM files, without requesting a new certificate. A renewal uses the parameters of the wacs.exe command that created it, so when changed parameters work, run that wacs.exe command again with them.
The script logs in as -UserName with -Password. Store the password in simple-acme's vault first, from the simple-acme folder: .\wacs.exe --vaultstore --vaultkey vault://json/netscaler --vaultsecret 'YOUR_PASSWORD' and give -Password '{vault://json/netscaler}' in --scriptparameters; simple-acme replaces it with the password when it runs the script. A renewal set up with -CredentialTarget reads the login from Windows Credential Manager as before.
Requirements
- Windows Server with Windows PowerShell 5.1, run as Administrator
- simple-acme, which runs the script after each issuance and renewal
Parameters
| -StorePath | Folder where simple-acme stores PEM files. |
|---|---|
| -FilePrefix | PEM filename prefix configured in simple-acme. |
| -nsHost | NetScaler management hostname, IP address, or URL. |
| -certName | SSL cert-key or cert-key bundle name on NetScaler. Use the existing name when renewing a certificate that is already bound. |
| -vServerName | One or more SSL vServers to bind. Comma-separated values are also accepted. |
| -UserName | The NetScaler account the script logs in with, together with -Password. |
| -Password | The account's password: simple-acme's vault reference '{vault://json/netscaler}' in --scriptparameters, or the password itself. simple-acme keeps a password given as itself in its renewal settings and its log on the server, and in PowerShell each $ and backtick in it needs a backtick before it. |
| -CredentialTarget | Windows Credential Manager target, used when -Password is not given. Defaults to NetScaler-acme-user. |
| -UseHttp | Use HTTP for NITRO instead of HTTPS when nsHost is not already a URL. |
| -ValidateManagementCertificate | Validate the NetScaler management TLS certificate. By default this script accepts the management certificate so it also works with self-signed ADC management certificates on Windows PowerShell 5.1. |
| -SniCert | Bind as an SNI certificate when vServerName is used. |
| -BindGlobalVpn | Bind the certificate to the global VPN certificate binding. |
| -SkipBinding | Upload and create/update the cert-key only. Do not bind it. |
| -SkipSaveConfig | Do not save the NetScaler running configuration after a successful update. |
| -DeploymentMode | Auto, CertKeyBundle, or Classic. Auto uses cert-key bundle when the appliance supports it and falls back to classic cert-key where needed. |
| -NoBundle | Do not set bundle=YES when creating a new SSL cert-key. |
| -NoDomainCheck | Pass nodomaincheck=true when updating an existing SSL cert-key. |
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\Install-NetScalerCert.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\Install-NetScalerCert.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\Install-NetScalerCert.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\Install-NetScalerCert.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.
Runs in simple-acme (formerly win-acme), Apache-2.0.
One script per server, or sslbrain does it for all your servers without scripts.
Feedback and improvements are welcome: info@fairssl.dk