ebekker / ACMESharp

An ACME client library and PowerShell client for the .NET platform (Let's Encrypt)
https://pkisharp.github.io/ACMESharp-docs/
1.21k stars 184 forks source link

Install-ACMECertificate Fails when bindings like net.pipe or net.tcp exist (without port information) #322

Closed daitj closed 5 years ago

daitj commented 6 years ago

321 Is the fix for this.

Using IIS Provider

Command used:

Install-ACMECertificate -CertificateRef cert-domains -Installer iis -InstallerParameters @{ 
 WebSiteRef = $IISWebsiteName
 BindingAddress = '0.0.0.0'
 BindingHost = ''
 BindingPort = 443
 Force = $true
} -VaultProfile $CustomVaultName

Exception Install-ACMECertificate : Value cannot be null.

PS C:\Windows\system32> $Error[1].Exception.StackTrace
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boole
n parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at ACMESharp.Providers.IIS.IisHelper.<>c__DisplayClass11_0.<ResolveSiteBindings>b__0(IisWebSiteBinding _) in C:\proj
cts\acmesharp\ACMESharp\ACMESharp.Providers.IIS\IisHelper.cs:line 231
   at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at ACMESharp.Providers.IIS.IisInstaller.Install(PrivateKey pk, Crt crt, IEnumerable`1 chain, IPkiTool cp) in C:\proj
cts\acmesharp\ACMESharp\ACMESharp.Providers.IIS\IisInstaller.cs:line 61
   at ACMESharp.POSH.InstallCertificate.ProcessRecord() in C:\projects\acmesharp\ACMESharp\ACMESharp.POSH\InstallCertif
cate.cs:line 228
   at System.Management.Automation.CommandProcessor.ProcessRecord()

Stack trace says this line is the culprit:

https://github.com/ebekker/ACMESharp/blob/3cb30fedb2d597415916b3f1ac9f447816c2e36a/ACMESharp/ACMESharp.Providers.IIS/IisHelper.cs#L231