* 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
}
}
Try{
$site_bindings=get-webbinding-name$args[0].name
}
Else
{
Try{
Get-WebBinding@bind_search_splat
}
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
}
Catch{
# 2k8r2 throws this error when you run get-webbinding with no bindings in iis
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
}
Else
{
$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.
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
}
Try{
$site_bindings=get-webbinding-name$args[0].name
}
Catch{
# 2k8r2 throws this error when you run get-webbinding with no bindings in iis
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{
Get-WebBinding@bind_search_splat
}
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
}
$splits=$binding.bindingInformation-split':'
if(
$args[0].protocol-eq$binding.protocol-and
$args[0].ipaddress-eq$splits[0]-and
$args[0].port-eq$splits[1]-and
$args[0].hostheader-eq$splits[2]
)
{
Return$binding
}
}
}
# create binding search splat
$binding_parameters=@{
Name=$name
Protocol=$protocol
Port=$port
IPAddress=$ip
Name=$name
Protocol=$protocol
Port=$port
IPAddress=$ip
}
# insert host header to search if specified, otherwise it will return * (all bindings matching protocol/ip)