* win_iis_webbinding: Fix bug with ipaddress * returning multiple bindings
instead of only the ones defined as *. Address possible future issues around
hostheader * by just disallowing it. Resolves 25473. Added new test for
this case.
Removed all validation for https binding collisions due to difficulty in
validating all cases in which they could or could not collide. As a
result, also removed return values relating to certificate data.
Updated testing and docs appropriately
* win_iis_webbinding: added break to remove binding loops
If(-not$_.Exception.Message.CompareTo('Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value'))
{
Throw$_.Exception.Message
}
}
}
}
Else
Catch{
{
# 2k8r2 throws this error when you run get-webbinding with no bindings in iis
Try{
If(-not$_.Exception.Message.CompareTo('Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value'))
Get-WebBinding@bind_search_splat
{
}
Throw$_.Exception.Message
Catch{
If(-not$_.Exception.Message.CompareTo('Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value'))
{
Throw$_.Exception.Message
}
}
}
Else{return}
}
}
}
FunctionGet-CertificateSubjects{
Param(
[string]$CertPath
)
If(-Not(Test-Path$CertPath))
{
Fail-Json-obj$result-message"Unable to locate certificate at $CertPath"
}
$cert=get-item$CertPath
If ([version][System.Environment]::OSVersion.Version-ge[version]6.2)
Foreach($bindingin$site_bindings)
{
{
$cert.DnsNameList.unicode
$splits=$binding.bindingInformation-split':'
}
Else
if(
{
$args[0].protocol-eq$binding.protocol-and
$san=$cert.extensions|Where-Object{$_.Oid.FriendlyName-eq'Subject Alternative Name'}
Fail-Json-obj$result-message"A conflicting binding has been found on the same ip $ip and port $port. To continue, you will either have to remove the offending binding or enable sni"
Fail-Json-obj$result-message"A conflicting binding has been found on the same ip $ip and port $port. To continue you will need to remove the existing binding or assign a new IP or Port to this one"
}
}
}
# add binding. this creates the binding, but does not apply a certificate to it.
# add binding. this creates the binding, but does not apply a certificate to it.
If(-not$_.Exception.Message.CompareTo('Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value'))
}
{
Catch{
Throw$_.Exception.Message
If(-not$_.Exception.Message.CompareTo('Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value'))
{
Throw$_.Exception.Message
}
}
}
Else{return}
}
}
Else
Foreach($bindingin$site_bindings)
{
{
Try{
$splits=$binding.bindingInformation-split':'
Get-WebBinding@bind_search_splat
}
if(
Catch{
$args[0].protocol-eq$binding.protocol-and
If(-not$_.Exception.Message.CompareTo('Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value'))
$args[0].ipaddress-eq$splits[0]-and
{
$args[0].port-eq$splits[1]-and
Throw$_.Exception.Message
$args[0].hostheader-eq$splits[2]
}
)
{
Return$binding
}
}
}
}
}
}
# create binding search splat
# create binding search splat
$binding_parameters=@{
$binding_parameters=@{
Name=$name
Name=$name
Protocol=$protocol
Protocol=$protocol
Port=$port
Port=$port
IPAddress=$ip
IPAddress=$ip
}
}
# insert host header to search if specified, otherwise it will return * (all bindings matching protocol/ip)
# insert host header to search if specified, otherwise it will return * (all bindings matching protocol/ip)