Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
FWest98 committed Mar 4, 2017
2 parents d1790e3 + a63425d commit 2806f6a
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 189 deletions.
36 changes: 24 additions & 12 deletions HSTS IIS Module.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,64 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HSTS IIS Module", "module\HSTS IIS Module.vcxproj", "{62DC9D78-388A-4533-8E57-6678CCE36138}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HSTS IIS Manager", "manager\HSTS IIS Manager.csproj", "{AF5A20AE-292F-4649-A09B-3EF4BDB98951}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "HSTS IIS Installer", "installer\HSTS IIS Installer.wixproj", "{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HSTS IIS Module", "module\HSTS IIS Module.vcxproj", "{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ia64 = Debug|ia64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ia64 = Release|ia64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{62DC9D78-388A-4533-8E57-6678CCE36138}.Debug|Any CPU.ActiveCfg = Debug|Win32
{62DC9D78-388A-4533-8E57-6678CCE36138}.Debug|x64.ActiveCfg = Debug|x64
{62DC9D78-388A-4533-8E57-6678CCE36138}.Debug|x64.Build.0 = Debug|x64
{62DC9D78-388A-4533-8E57-6678CCE36138}.Debug|x86.ActiveCfg = Debug|Win32
{62DC9D78-388A-4533-8E57-6678CCE36138}.Debug|x86.Build.0 = Debug|Win32
{62DC9D78-388A-4533-8E57-6678CCE36138}.Release|Any CPU.ActiveCfg = Release|Win32
{62DC9D78-388A-4533-8E57-6678CCE36138}.Release|x64.ActiveCfg = Release|x64
{62DC9D78-388A-4533-8E57-6678CCE36138}.Release|x64.Build.0 = Release|x64
{62DC9D78-388A-4533-8E57-6678CCE36138}.Release|x86.ActiveCfg = Release|Win32
{62DC9D78-388A-4533-8E57-6678CCE36138}.Release|x86.Build.0 = Release|Win32
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|ia64.ActiveCfg = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|ia64.Build.0 = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|x64.ActiveCfg = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|x64.Build.0 = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|x86.ActiveCfg = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Debug|x86.Build.0 = Debug|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|Any CPU.Build.0 = Release|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|ia64.ActiveCfg = Release|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|ia64.Build.0 = Release|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|x64.ActiveCfg = Release|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|x64.Build.0 = Release|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|x86.ActiveCfg = Release|Any CPU
{AF5A20AE-292F-4649-A09B-3EF4BDB98951}.Release|x86.Build.0 = Release|Any CPU
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Debug|Any CPU.ActiveCfg = Debug|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Debug|Any CPU.Build.0 = Debug|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Debug|ia64.ActiveCfg = Debug|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Debug|x64.ActiveCfg = Debug|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Debug|x64.Build.0 = Debug|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Debug|x86.ActiveCfg = Debug|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Debug|x86.Build.0 = Debug|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Release|Any CPU.ActiveCfg = Release|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Release|ia64.ActiveCfg = Release|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Release|x64.ActiveCfg = Release|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Release|x86.ActiveCfg = Release|x86
{5CAA58C6-D65D-43B4-91CA-0B3A18B5C434}.Release|x86.Build.0 = Release|x86
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Debug|Any CPU.ActiveCfg = Debug|Win32
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Debug|ia64.ActiveCfg = Debug|Win32
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Debug|x64.ActiveCfg = Debug|x64
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Debug|x64.Build.0 = Debug|x64
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Debug|x86.ActiveCfg = Debug|Win32
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Debug|x86.Build.0 = Debug|Win32
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Release|Any CPU.ActiveCfg = Release|Win32
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Release|ia64.ActiveCfg = Release|Win32
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Release|x64.ActiveCfg = Release|x64
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Release|x64.Build.0 = Release|x64
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Release|x86.ActiveCfg = Release|Win32
{B697A6DE-B20A-4DC3-90BE-9D31DE1D6BDF}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
43 changes: 14 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,35 @@
A module for IIS which enables HTTP Strict Transport Security compliant with the HSTS Draft Specification (RFC 6797). As of version 2.0 the module can be configured to redirect insecure requests.

## Downloads & Documentation ##
[Downloads of the installers and binaries are available from the CodePlex project site](https://hstsiis.codeplex.com)
[Downloads of the installers and binaries are available from GitHub](https://github.com/FWest98/hsts-iis-module/releases)

Documentation is made available [in the documentation folder](documentation) of this repository. Documentation topics include [installation](documentation/Installation.md), [enabling HSTS](documentation/Enabling HSTS.md), and an assortment of [frequently asked questions](documentation/Frequently Asked Questions.md).

## Project Structure ##
The project is split into three components: module, manager, installer.
The project is split into three components: the module, the manager and the installer.

### module ###
The 'module' sub-project is the work horse of the project. Developed in C++ the output of this is the actual IIS module, which could be installed and used standalone without the other components. It is responsible for subscribing to the events, injecting the HSTS header and performing the redirect (if necessary).
### HSTS IIS Module ###
This project is the work horse of the plug-in. Developed in C++ the output of this is the actual IIS module, which could be installed and used standalone without the other components. It is responsible for subscribing to the events, injecting the HSTS header and performing the redirect (if necessary).

### manager ###
The 'manager' sub-project is the extension to the IIS manager (inetmgr.exe) and is developed in C#. This component gives the user a graphical interface to the configuration options.
### HSTS IIS Manager ###
The 'manager' project is the extension to the IIS manager (inetmgr.exe) and is developed in C#. This component gives the user a graphical interface to the configuration options.

### installer ###
### HSTS IIS Installer ###
Unsurprisingly, this subject produces an MSI installer which handles the copies the DLLs and modifies the IIS configuration. It is developed using the [WIX toolset](http://wixtoolset.org/).

## Tooling ##
The project uses some unconventional (within the Microsoft development environment) tooling. Specifically, the use of [Gradle](http://www.gradle.org/). I strongly believe in reducing the number of hurdles to first time developers. Ideally, someone who has no prior knowledge or skills without any tools installed, should be able to download and compile the project. Paid development tools such as Visual Studio obviously work against this. Yes, Visual Studio Express is free, but it doesn't allow for the installation of plugins and therefore WIX would need to be compiled extrnally. I also believe that IDEs such as Visual Studio can often make the process of compiling appear to be almost magical and can be very opaque.

Gradle allows me to remove a lot of these hurdles. It comes out of the box with [C++ support](http://www.gradle.org/docs/current/userguide/nativeBinaries.html), although the user must have the Visual C++ compiler installed. It also has a powerful API which means that I can use it to compile the C# and WIX whilst taking advantage of features such as akipping od up-to-date tasks.
This project uses the Visual Studio built-in tooling to compile, build and run C++/C# code. Using the WiX Plugin, the installer can also be built. The VS solution is currently compatible with version VS2015 and all binaries are compiled with the same version of VS. Any other combination of IDE/compiler might result in unexpected behaviour or other problems.

## Building and Compiling ##

### Prerequisites ###
If you would like to compile the extension for yourself you will need a few prerequisites intalled:
* Visal C++ Compiler - To build the 'module'
* .NET Framework 2.0 (must be 2.0) - To build the 'manager'
* IIS 7.0 or above - Contains some libraries required for the 'manager'
* WIX toolset - To build the 'installer'

### Build ###
To build the entire project:

1. Download the source code (using git, or as zip)
2. Open a command prompt
3. Change to the source directory
4. Run 'gradlew buildinstaller'

The 'buildinstaller' task will build all of the sub-components and then build the installer. It will output the installer to installer/build/bin.
* Visual Studio 2015 (Community) - To build the module and the manager
* WiX Toolset plugin - To build the installer
* IIS 7.0 or above - Contains some dependencies of the manager that are required to build

### A note on Strong Name Signing ###
The manager DLL must be signed in order to be installed into the Global Assembly Cache. It is a security issue to publish the private key used to sign the DLL which presents a bit of an issue. I wanted to ensure that the build process was as simple as possible so the instructions above will build the extension using a key that is included in the project and is therefore insecure. If you wish to build it with your own strong name key use the following commands:

1. gradlew compileCS -Psnk=YourSNKFile.snk
2. Locate the public key token of the generated file (you can use 'sn.exe -T path/to/file.dll' in the .NET SDK)
3. gradlew buildinstaller -PmanagerHash=YourHash
The manager DLL must be signed in order to be installed into the Global Assembly Cache. It is a security issue to publish the private key used to sign the DLL which presents a bit of an issue. I wanted to ensure that the build process was as simple as possible so the instructions above will build the extension using a key that is included in the project and is therefore insecure. If you wish to build it with your own strong name key, please modify the settings in Visual Studio to do so.

Note: the official downloads of the project are signed with a secure key, not the one included in the project. It is sad that others cannot build exactly the same artifacts that are downloaded from the project site, but this is the best compromise I could come up with.

Expand All @@ -64,6 +47,8 @@ An additional driver for such a module is the seriousness of attack vectors such

Thanks to Phill from [Dionach](http://www.dionach.com/) for the fantastic [Strip Headers](https://github.com/Dionach/StripHeaders/) IIS extension which is, aside from a great extension, one of the best references for developing a native IIS module.

Thanks to [Andrew Bancroft](https://github.com/andrewcbancroft) for his great work on improving this plugin and its documentation!

Thanks also to everyone that has taken the time to reported issues and suggest improvements.

Special thanks to Shane Argo for the great work he has done for the first versions of this plugin!
12 changes: 12 additions & 0 deletions installer/HSTS IIS Installer.wax
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-16"?>
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DeployedProjects>
<string>manager\HSTS IIS Manager.csproj</string>
<string>module\HSTS IIS Module.vcxproj</string>
</DeployedProjects>
<DirectoryMappings>
<Item Key="" Value="InetsrvDir" />
</DirectoryMappings>
<FileMappings />
<DeploySymbols>false</DeploySymbols>
</Configuration>
3 changes: 2 additions & 1 deletion installer/HSTS IIS Installer.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</ProjectReference>
<ProjectReference Include="..\module\HSTS IIS Module.vcxproj">
<Name>HSTS IIS Module</Name>
<Project>{62dc9d78-388a-4533-8e57-6678cce36138}</Project>
<Project>{b697a6de-b20a-4dc3-90be-9d31de1d6bdf}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
Expand All @@ -46,6 +46,7 @@
<Folder Include="resources\" />
</ItemGroup>
<ItemGroup>
<Content Include="HSTS IIS Installer.wax" />
<Content Include="resources\license.rtf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
29 changes: 24 additions & 5 deletions installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
<ComponentRef Id="HstsIisModuleDLL" />
<ComponentRef Id="SchemaXML" />
<ComponentRef Id="ApplicationHostSectionElement" />
<ComponentRef Id="ApplicationHostLocationModuleAddElement" />
<ComponentRef Id="ApplicationHostModuleAddElement" />
<!--<ComponentRef Id="ApplicationHostLocationModuleAddElement" />-->
<ComponentRef Id="ApplicationHostGlobalModuleAddElement" />
<!--<ComponentRef Id="ApplicationHostModuleList"/>-->
</ComponentGroup>

<ComponentGroup Id="ManagerComponent">
Expand Down Expand Up @@ -88,7 +90,25 @@
ElementPath="/configuration/configSections/sectionGroup[\[]@name='system.webServer'[\]]" Sequence='103'
VerifyPath="/configuration/configSections/sectionGroup[\[]@name='system.webServer'[\]]/section[\[]@name='hsts'[\]]" />
</Component>
<Component Id='ApplicationHostLocationModuleAddElement' Guid='A44EEABB-796D-416E-97AA-49A2BED9D6F4' Win64='yes'>
<Component Id='ApplicationHostModuleAddElement' Guid='621A4292-B1CF-42BA-ABA3-8DC6E9B8B9F2' Win64='yes'>
<!--<Condition><![CDATA[Installed OR (IISMAJORVERSION AND NOT IISMAJORVERSION = "#7")]]></Condition>-->
<!--<util:XmlConfig Id='ApplicationHostModuleList' On='install' Action='create'
File='[InetsrvDir]config\applicationHost.config' Node='element'
ElementPath="/configuration/system.webServer" Name="modules" Sequence="1"
VerifyPath="/configuration//system.webServer/modules" />-->
<util:XmlConfig Id='ApplicationHostModuleAddElement' On='install' Action='create'
File='[InetsrvDir]config\applicationHost.config' Node='element'
ElementPath="/configuration//system.webServer/modules" Name="add" Sequence="10"
VerifyPath="/configuration//system.webServer/modules/add[\[]@name='HstsIisModule'[\]]" />
<util:XmlConfig Id='ApplicationHostModuleNameAttrib' File='[InetsrvDir]config\applicationHost.config'
ElementPath='ApplicationHostModuleAddElement' Sequence='11' Name='name' Value='HstsIisModule' />
<util:XmlConfig Id='ApplicationHostModuleAddElementRemove' On='uninstall' Action='delete'
File='[InetsrvDir]config\applicationHost.config' Node='element'
ElementPath="/configuration//system.webServer/modules" Sequence='104'
VerifyPath="/configuration//system.webServer/modules/add[\[]@name='HstsIisModule'[\]]" />
</Component>
<!--<Component Id='ApplicationHostLocationModuleAddElement' Guid='A44EEABB-796D-416E-97AA-49A2BED9D6F4' Win64='yes'>
<!-<Condition><![CDATA[Installed OR (IISMAJORVERSION AND IISMAJORVERSION = "#7")]]></Condition>-
<util:XmlConfig Id='ApplicationHostLocationModuleAddElement' On='install' Action='create'
File='[InetsrvDir]config\applicationHost.config' Node='element'
ElementPath="/configuration/location[\[]@path=''[\]]/system.webServer/modules" Name="add" Sequence="13"
Expand All @@ -99,7 +119,7 @@
File='[InetsrvDir]config\applicationHost.config' Node='element'
ElementPath="/configuration/location[\[]@path=''[\]]/system.webServer/modules" Sequence='105'
VerifyPath="/configuration/location[\[]@path=''[\]]/system.webServer/modules/add[\[]@name='HstsIisModule'[\]]" />
</Component>
</Component>-->
<Component Id='ApplicationHostGlobalModuleAddElement' Guid='3605417F-5C93-4981-939E-18860ED4053D' Win64='yes'>
<util:XmlConfig Id='ApplicationHostGlobalModuleAddElement' On='install' Action='create'
File='[InetsrvDir]config\applicationHost.config' Node='element'
Expand All @@ -117,7 +137,7 @@
</Component>
<Directory Id="InetsrvDir">
<Component Id="HstsIisModuleDLL" Guid="F5CF744D-ED1D-4C3C-877A-2941385AFEE1" Win64="yes">
<File Id="HstsIisModuleDLL" Name='HSTS-IIS-Module.dll' Source='$(var.HSTS IIS Module.TargetDir)\$(var.HSTS IIS Module.TargetFileName)' KeyPath='yes' />
<File Id="HstsIisModuleDLL" Name='$(var.HSTS IIS Module.TargetFileName)' Source='$(var.HSTS IIS Module.TargetDir)\$(var.HSTS IIS Module.TargetFileName)' KeyPath='yes' />
</Component>
<Directory Id="InetsrvConfigDir" Name="config">
<Directory Id="InetsrvSchemaDir" Name="schema">
Expand All @@ -130,5 +150,4 @@
</Directory>

</Product>

</Wix>
4 changes: 2 additions & 2 deletions manager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
[assembly: AssemblyProduct("HSTS IIS Module")]
[assembly: AssemblyCopyright("Copyright © Floris Westerman 2016")]
[assembly: AssemblyTrademark("Floris Westerman")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyVersion("2.3.0.0")]
[assembly: AssemblyFileVersion("2.3.0.0")]

[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand Down
37 changes: 37 additions & 0 deletions module/HSTS IIS Module.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="hstsmodule.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="hstsmodule.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="hstsmodule.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
Loading

0 comments on commit 2806f6a

Please sign in to comment.