Server Name Indication in IIS 8

Server Name Indication (SNI)

With Windows 2012 server Microsoft’s Internet Information Services 8.0 supports Server Name Indication (SNI). SNI is an extension to the TLS protocol that allows the web server to host multiple virtual domains in combination with HTTPS.

Although you could have registered different host names for different web sites in IIS < 8 things got tricky if you needed to have them secured by SSL/TLS. Actually it is impossible, because the web server is unable to extract the host name information from the HTTPS request header, because the packet is encrypted already on the transport layer before it arrives on the HTTPS stack of the web server. Routing the HTTP request to virtual domains is only possible if you assign different IP addresses to the web sites.

SNI fixes this problem by a extending TLS in a way that the client sends the requested virtual domain as part of the TLS negotiation.The server keeps the information in the TLS session and is later on capable to route the HTTPS requests to the correct domain.

Server and client support

Because SNI extends the TLS negotiation both parties, the client and the server, need to support Server Name Indication. Forntunately almost all browsers do that allready (the wikipedia article about SNI provides a detailed list).

Configuration sample in IIS 8

Let’s say we have two web sites on our server, called foo.com and bar.com.

image

If we now add an HTTPS binding to the foo.com site we have a new option in IIS 8, called Require Server Name Indication.

image

All we need to do is to apply the certificates to both web sites and check the Require SNI option and then we can access both web sites using HTTPS on the same server. Magic.

image

Advertisements

Designing a mobile RSS 2.0 feed reader app that uses a Cross Media Data Relation

This is the second post of a series of blog posts about new Data Relations feature in DirectSmile Cross Media.

In the previous post I explained who create a Data Relation that consumes an RSS 2.0 Feed. In the second and third part of the series I show how we can design a mobile application that uses the Data Relation.

Design

All the data relation needs is a URL to the feed provider. Having this in mind I will create a mobile application that contains basically two pages.

image

The first page should show a few buttons to present a selection of RSS feeds. In this example I choose some news channels.

Selecting one of those channels will lead me to a new page that shows a list of items of the feed I selected.

image

Let’s say I selected the DirectSmile Blog RSS feed (which is the button with in the upper right corner in the example) then I will see a list of the latest DirectSmile blog posts.

Because the RSS 2.0 sepefication supports media content it’s easy to show images as well.

To top this we could also check the media content type, and if it’s audio (like in the .Net Rocks RSS feed in the example is providing) we could show a HTML5 audio player.

image

The media content type is field in the Data Relation, so it’s easy for us to setup a condition that takes advantage of this later on in the designer.

Application structure diagramm

Here’s a diagramm to better explain the workflow of the sample application.

image

Next

In the next part of this series I will show you how to build this application using the DirectSmile Cross Media Designer.

Have fun,

Oliver

DSMX Data Relation to consume RSS 2.0 feeds 1/2

A Data relation that consumes an RSS 2.0 XML data stream is pretty straight forward to implement. All it needs is basically an URL pointing to the RSS Feed provider and a .net WebClient object that downloads the XML from the server and deserializes it into a data relation table.

But let’s start by implementing the data relation. To do so, create a new class library project in Visual Studio, doesn’t matter if C# or VB.NET, I’m using vb.

Add a reference to the DataRelationInterfaces.dll and create a new class, named RssFeedRelation, which implements IDataRelation.

GetMetaData

The GetMetaData method is called by DSMX to get metadata information from the relation. This is where we add two tables, one that will provide basic information like link, description and name of the RSS feed. A second table that contains a list of all available RSS feed items.

We also want to add to parameters, one for the server URL and another for the provided encoding. Because in most cases the encoding is utf-8, we set this as the default. I also added a default for the Feed URL as well.

Public Sub GetMetaData(ByVal accountID As Integer, ByVal Language As String, ByVal MetaData As IhtDataProviderMetaData) Implements IDataRelation.GetMetaData
     MetaData.AddTable(RssFeedPropertiesTable)
     MetaData.AddTable(RssFeedTable)
     MetaData.AddParameter("Encoding", "RSS Feed XML content encoding", "utf-8", False)
     MetaData.AddParameter("RssFeedUrl", "Url pointing to the RSS feed XML.", "http://support.directsmile.de/support/rss.aspx", False)
End Sub

LoadData

Implementing the LoadData method that is actually called by DSMX to get the feed data is also no black magic at all.

 Public Sub LoadData(ByVal table As IhtDataTable) Implements IDataRelation.LoadData
        Dim url As String = table.GetParameterValue("RssFeedUrl")
        Dim enc As String = table.GetParameterValue("Encoding")
        If table.Query.TableName = RssFeedTable Then
            AddFeedItemTableFields(table)
            Dim itms = LoadFeedItems(url, enc)
            If Not itms Is Nothing AndAlso itms.Count > 0 Then
                Dim pagedResult As IEnumerable(Of RssItem) = GetPagedResultSet(table, itms)
                AddFeedItems(table, pagedResult)
            End If
        ElseIf table.Query.TableName = RssFeedPropertiesTable Then
            AddFeedPropertiesTableFields(table)
            Dim itms = LoadFeedItems(url, enc)
            If Not itms Is Nothing AndAlso itms.Count > 0 Then
                AddFeedProperties(table, itms)
            End If
   Else
            Throw New ArgumentException("No valid table name found.")
End If

That method does two things, first it checks what table was requested by DSMX. It contacts the Feed providing server and downloads the feed XML to return either the list of items or just the feed header.

LoadItems

The LoadItems method instanciates a WebClient and downloads the XML.

Public Function LoadFeedItems(url As String, enc As String) As IEnumerable(Of RssItem)
        If String.IsNullOrEmpty(url) Then
            Throw New ArgumentException("RSS feed URL must have a value.")
        End If
        Dim wc As New WebClient()
        wc.Encoding = Encoding.GetEncoding(enc)
        Dim result = wc.DownloadString(New Uri(url))
        If String.IsNullOrEmpty(result) Then
            Throw New ArgumentException("RSS feed URL returned no valid RSS data [" & url & "]")
        End If
        Dim rssFeedItems = New RssItems
        rssFeedItems.Deserialize(result)
        Return rssFeedItems
End Function

If the download was successful we can deserialize the XML data into a CLR object. Very convenient using XML literals in VB.NET.

Public Sub Deserialize(xml As String)
        If String.IsNullOrEmpty(xml) Then
            Throw New ArgumentException("Feed xml contains to data.")
        End If
        Dim doc As XDocument = XDocument.Parse(xml)
        If doc Is Nothing Then
            Throw New Exception("Failed to parse rss feed xml.")
        End If
        Title = doc...<channel>.<title>.Value
        Link = doc...<channel>.<link>.Value
        Description = doc...<channel>.<description>.Value
        For Each elem In From element In doc...<channel>.<item>
            If elem.Name = "item" Then
                Add(New RssItem With {.Author = elem.<author>.Value,
                                      .Description = elem.<description>.Value,
                                      .Link = elem.<link>.Value,
                                      .PubDate = TryConvertToDate(elem.<pubDate>.Value),
                                      .Title = elem.<title>.Value,
                                      .EnclosureUrl = elem.<enclosure>.@url,
                                      .EnclosureType = elem.<enclosure>.@type})
            End If
        Next
End Sub

Conclusion

Basically that’s all it needs to consume RSS feeds. In part 2 of this short series I will create a little mobile RSS feed reader to show you easy it is to integrate this data relation into a cross media server.

Have fun

Oliver