Updated sitehelper to throw if manipulating require_sni property on systems that do not have SNI support.

This commit is contained in:
Jimmy Campbell 2017-06-27 09:13:12 -07:00
Родитель 61f42e8df9
Коммит 8d68c712e2
2 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

@ -644,8 +644,18 @@ namespace Microsoft.IIS.Administration.WebServer.Sites
binding.SslFlags |= SslFlags.CentralCertStore;
}
if (requireSni.HasValue && requireSni.Value && binding.Schema.HasAttribute(sslFlagsAttribute)) {
binding.SslFlags |= SslFlags.Sni;
if (requireSni.HasValue) {
if (!binding.Schema.HasAttribute(sslFlagsAttribute)) {
// throw on IIS 7.5 which does not have SNI support
throw new ApiArgumentException("binding.require_sni", "SNI not supported on this machine");
}
if (requireSni.Value) {
binding.SslFlags |= SslFlags.Sni;
}
else {
binding.SslFlags &= ~SslFlags.Sni;
}
}
}

Просмотреть файл

@ -17,6 +17,7 @@ namespace Microsoft.IIS.Administration.Tests
using Core.Utils;
using System.Net;
using System.IO;
using System.Threading;
public class Sites
{
@ -64,7 +65,7 @@ namespace Microsoft.IIS.Administration.Tests
JObject site = CreateSite(client, TEST_SITE_NAME, TEST_PORT, Configuration.TEST_ROOT_PATH);
JObject cachedSite = new JObject(site);
WaitForStatus(client, site);
WaitForStatus(client, ref site);
Assert.True(site != null);
@ -108,6 +109,8 @@ namespace Microsoft.IIS.Administration.Tests
JObject newSite = JsonConvert.DeserializeObject<JObject>(result);
WaitForStatus(client, ref newSite);
Assert.True(Utils.JEquals<bool>(site, newSite, "server_auto_start"));
Assert.True(Utils.JEquals<string>(site, newSite, "physical_path"));
Assert.True(Utils.JEquals<string>(site, newSite, "enabled_protocols"));
@ -523,16 +526,17 @@ namespace Microsoft.IIS.Administration.Tests
return Globals.Success(responseMessage);
}
private void WaitForStatus(HttpClient client, JObject site)
private void WaitForStatus(HttpClient client, ref JObject site)
{
string res;
int refreshCount = 0;
while (site.Value<string>("status") == "unknown") {
refreshCount++;
if (refreshCount > 100) {
if (refreshCount > 500) {
throw new Exception();
}
Thread.Sleep(10);
client.Get(Utils.Self(site), out res);
site = JsonConvert.DeserializeObject<JObject>(res);
}