Permalink
Browse files

Missing file change for Acme.

  • Loading branch information...
1 parent 96774be commit 31df15f02a516c83817ccd5c3456bbf6484e1800 @Bobris committed Dec 22, 2015
Showing with 11 additions and 0 deletions.
  1. +11 −0 NowinAcme/NowinAcme.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Threading.Tasks;
using Oocx.ACME.Common;
@@ -38,6 +39,16 @@ public void Error(string message, params object[] args)
}
}
+ public static Task RedirectToHttps(IDictionary<string, object> env)
+ {
+ var query = (string)env["owin.RequestQueryString"];
+ var loc = "https://" + ((IDictionary<string, string[]>)env["owin.RequestHeaders"])["Host"].First() +
+ env["owin.RequestPath"] + (query.Length > 0 ? "?" + query : "");
+ env["owin.ResponseStatusCode"] = 301;
+ ((IDictionary<string, string[]>)env["owin.ResponseHeaders"]).Add("Location", new[] { loc });
+ return Task.CompletedTask;
+ }
+
// This must run on server port 80 - Let's encrypt does not allow anything else
public static Func<IDictionary<string, object>, Task> Use(Func<IDictionary<string, object>, Task> next, IAcmeConfiguration cfg)
{

0 comments on commit 31df15f

Please sign in to comment.