我有一個非常「簡單」的問題。我有一個WCF服務器應該只接受TLS 1.2連接。但每次我通過Firefox或任何瀏覽器連接到它時,它都使用TLS 1.0。WCF服務器接受TLS 1.0連接
.NET Framework-Version是4.6.1,所以它應該支持TLS 1.2。 這裏是我的app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="WCFServer.Properties.Settings.ConnectionString" connectionString="SomeConnectionString" />
</connectionStrings>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="TestNetTcpBinding">
<reliableSession enabled="true" />
<security>
<message clientCredentialType="Windows" algorithmSuite="Basic256Sha256Rsa15" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="MyCustomAttributeBehavior">
<Validator />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="mex" policyVersion="Default" />
</behavior>
</serviceBehaviors>
</behaviors>
<extensions>
<behaviorExtensions>
<add name="Validator" type="WCFServer.RightAttribute.MyBehaviorSection, WCFServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<services>
<service behaviorConfiguration="DefaultBehavior" name="WCFServer.Services.Implementations.BusinessService">
<endpoint address="ProductService" behaviorConfiguration="MyCustomAttributeBehavior"
binding="netTcpBinding" bindingConfiguration="TestNetTcpBinding"
contract="WCFServer.Services.Interfaces.IProductService" />
<endpoint address="UserService" behaviorConfiguration="MyCustomAttributeBehavior"
binding="netTcpBinding" bindingConfiguration="TestNetTcpBinding"
contract="WCFServer.Services.Interfaces.IUserService" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://SomeHost/WCFService/Service" />
<add baseAddress="https://SomeHost/WCFService/Service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.4000" newVersion="4.1.0.4000" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我希望我沒有****了XML太差的格式。對不起。 我把它放在控制檯應用程序中來測試。 這是我的主要方法(在這裏我嘗試將SecurityProtocol設置爲只TLS 1.2)
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var host = new ServiceHost(typeof(BusinessService));
host.Open();
Console.WriteLine("Services Ready");
Console.WriteLine("Press any button to close services.");
Console.Read();
host.Close();
Environment.Exit(0);
我BusinessService
類實現既IUserService
和IProductService
。您可以忽略MyCustomAttributeBehavior
。只是一些「攔截器」的東西,這應該不重要。
編輯:證書是確定的。另外firefox說。 證書是否必須符合特殊要求?我不這麼認爲,但我不確定。
我已經嘗試在host.Open()
之前和之後設置SecurityProtocol
。兩者都沒有工作。
任何幫助表示感謝。
謝謝!