Created
May 13, 2018 16:45
-
-
Save geea-develop/6c3127af802f3d86390d930ff0a5b515 to your computer and use it in GitHub Desktop.
Windows IIS Letsencrypt Powershell create certificate according to ebekker/ACMESharp Quick-Start and @RickStrahl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #install-Module -Name ACMESharp | |
| import-module ACMESharp | |
| $email = "mailto:[email protected]" | |
| $domain = "codepaste.net" | |
| $alias = "codepaste" | |
| $iissitename = "codepaste.net" | |
| $certname = "codepaste$(get-date -format yyyy-MM-dd--HH-mm)" | |
| $pfxfile = "c:\Admin\Certs\$certname.pfx" | |
| $initializevault = $FALSE | |
| $createregistration = $FALSE | |
| $createalias = $TRUE | |
| # Change to the Vault folder | |
| cd C:\ProgramData\ACMESharp\sysVault | |
| # First time on the machine - intiialize vault | |
| if($initializevault) | |
| { | |
| Initialize-ACMEVault | |
| } | |
| Get-ACMEVault | |
| if($createregistration) | |
| { | |
| # Set up new 'account' tied to an email address | |
| New-AcmeRegistration -Contacts "$email" -AcceptTos | |
| } | |
| if($createalias) | |
| { | |
| # Associate a new site | |
| New-AcmeIdentifier -Dns $domain -Alias $alias | |
| # Prove the site exists and is accessible | |
| Complete-ACMEChallenge $alias -ChallengeType http-01 -Handler iis -HandlerParameters @{WebSiteRef="$iissitename"} | |
| # Validate site | |
| Submit-ACMEChallenge $alias -ChallengeType http-01 | |
| # check until valid or invalid - pending | |
| Update-ACMEIdentifier $alias -ChallengeType http-01 | |
| Update-ACMEIdentifier $alias -ChallengeType http-01 | |
| } | |
| # Generate a certificate | |
| New-ACMECertificate ${alias} -Generate -Alias $certname | |
| #Submit the certificate | |
| Submit-ACMECertificate $certname | |
| # Hit until values are filled in | |
| update-AcmeCertificate $certname | |
| pause | |
| # Export Certifiacte to PFX file | |
| Get-ACMECertificate $certname -ExportPkcs12 $pfxfile | |
| pause | |
| # manually install the certificate | |
| certutil -importPFX "c:\Admin\Certs\$certname" –p password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment