SSL & BlogEngine

Topics: ASP.NET 2.0, Business Logic Layer
Oct 11, 2012 at 11:02 PM


  I've been a long time user of BlogEngine and recently did a fresh install for a new blog.  The new blog only has SSL enabled and does not allow connections to port 80.  It turns out that BlogEngine does not like this configuration, specifically the compression for web resources fails.  This is because the Close method in WebResourceFilter.cs does not respect HTTPS urls and always passes in HTTP for the RetrieveRemoteFile method.

 A simple way to make this work using SSL, is set compresswebresource to False in settings.xml in the App_Data folder.

  I don't have time to do a proper fix at the moment, but I will take a look at it this weekend.

 - Jeff

Nov 23, 2012 at 10:16 PM

Quick update.  This turns out to be a much bigger issue than first thought.  It breaks URLs all over BlogEngine.

Anyway, after much delay I had a chance to take a look at this.  The root of the issue is in BlogEngine.Core Blog.cs.  Specifically the AbsoluteWebRoot method does not set the correct uri.Scheme from the context.Request.  The fix is to set:

uri.Scheme = context.Request.Url.Scheme;

after the UriBuilder is created.  I did it on line 727 in BE 2.7.

UriBuilder uri = new UriBuilder();
if (!string.IsNullOrWhiteSpace(this.Hostname))
    uri.Host = this.Hostname;
    uri.Host = context.Request.Url.Host;
    if (!context.Request.Url.IsDefaultPort)
        uri.Port = context.Request.Url.Port;
uri.Scheme = context.Request.Url.Scheme;
uri.Path = RelativeWebRoot;

 - Jeff