djhayman
djhayman

Reputation: 1167

Why is ServicePointManager.SecurityProtocol different in console application and IIS website on the same machine?

I am trying to update a set of projects to .NET 4.6.1 in order to get TLS 1.2 support. The solution contains a mix of class libraries, console applications, WebForms websites, and MVC websites.

I have already changed every project and website to target .NET 4.6.1, and recompiled everything.

Now, if I check the default value for ServicePointManager.SecurityProtocol in one of the console applications, then I get the following:

Tls, Tls11, Tls12

But if I check the default value for ServicePointManager.SecurityProtocol in one of the WebForms websites running under IIS, then I get the following:

Ssl3, Tls

So I can see different values for ServicePointManager.SecurityProtocol on the same machine when comparing a console application and a WebForms website under IIS.

I can confirm that the WebForms websites have the following in Web.config under "system.web":

<compilation debug="true" targetFramework="4.6.1">

But it appears as though IIS is ignoring the "targetFramework" attribute.

Is there something that I need to do in IIS to get this to work as expected?

UPDATE:

It appears that IIS is actually honoring the "targetFramework" attribute, but ServicePointManager.SecurityProtocol still returns a different default value under IIS when compared to a console application.

Upvotes: 4

Views: 1775

Answers (1)

djhayman
djhayman

Reputation: 1167

OK - I worked it out.

To change a website's target framework, you right-click it, click "Property Pages", then change "Target Framework" on the "Build" page.

If you do this, then in will change the "targetFramework" attribute on the "compilation" node under the "system.web" node:

<compilation targetFramework="4.6.1" />

But this is not enough - you also need to change the "targetFramework" attribute on the "httpRuntime" node under the "system.web" node:

<httpRuntime targetFramework="4.6.1" />

And now, both the website under IIS and the console application report back the same thing for ServicePointManager.SecurityProtocol.

Upvotes: 6

Related Questions