diff --git a/letsencrypt-win-simple/Program.cs b/letsencrypt-win-simple/Program.cs index bf057091d..a315ce7dd 100644 --- a/letsencrypt-win-simple/Program.cs +++ b/letsencrypt-win-simple/Program.cs @@ -227,16 +227,16 @@ static void Auto(TargetBinding binding) { var pfxFilename = GetCertificate(binding); - if (options.Test && !options.Renew) - { - Console.WriteLine($"\nDo you want to install the .pfx into the Certificate Store? (Y/N) "); - if (!PromptYesNo()) - return; - } + //if (options.Test && !options.Renew) + //{ + // Console.WriteLine($"\nDo you want to install the .pfx into the Certificate Store? (Y/N) "); + // if (!PromptYesNo()) + // return; + //} X509Store store; X509Certificate2 certificate; - InstallCertificate(pfxFilename, out store, out certificate); + InstallCertificate(binding, pfxFilename, out store, out certificate); if (!options.Renew) { @@ -272,24 +272,50 @@ private static void ConfigureBinding(TargetBinding binding, X509Store store, X50 } else { + Console.WriteLine($" Adding https Binding"); var iisBinding = site.Bindings.Add(":443:" + binding.Host, certificate.GetCertHash(), store.Name); iisBinding.Protocol = "https"; + // only do this for IIS 8+ and only if users want it + //iisBinding.SetAttributeValue("sslFlags", 1); } - Console.WriteLine($" Commiting binding changes to IIS"); + Console.WriteLine($" Committing binding changes to IIS"); iisManager.CommitChanges(); } } - private static void InstallCertificate(string pfxFilename, out X509Store store, out X509Certificate2 certificate) + //public Version GetIisVersion() + //{ + // using (RegistryKey componentsKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\InetStp", false)) + // { + // if (componentsKey != null) + // { + // int majorVersion = (int)componentsKey.GetValue("MajorVersion", -1); + // int minorVersion = (int)componentsKey.GetValue("MinorVersion", -1); + + // if (majorVersion != -1 && minorVersion != -1) + // { + // return new Version(majorVersion, minorVersion); + // } + // } + + // return new Version(0, 0); + // } + //} + + private static void InstallCertificate(TargetBinding binding, string pfxFilename, out X509Store store, out X509Certificate2 certificate) { Console.WriteLine($" Opening Certificate Store"); store = new X509Store(StoreName.My, StoreLocation.LocalMachine); store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite); Console.WriteLine($" Loading .pfx"); - certificate = new X509Certificate2(pfxFilename, ""); + + // See http://paulstovell.com/blog/x509certificate2 + certificate = new X509Certificate2(pfxFilename, "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); + certificate.FriendlyName = $"{binding.Host} {DateTime.Now}"; + Console.WriteLine($" Adding Certificate to Store"); store.Add(certificate); diff --git a/letsencrypt-win-simple/Properties/AssemblyInfo.cs b/letsencrypt-win-simple/Properties/AssemblyInfo.cs index 7a0d9dc1c..677b1f5d1 100644 --- a/letsencrypt-win-simple/Properties/AssemblyInfo.cs +++ b/letsencrypt-win-simple/Properties/AssemblyInfo.cs @@ -33,4 +33,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/letsencrypt-win-simple/app.manifest b/letsencrypt-win-simple/app.manifest new file mode 100644 index 000000000..3729cd826 --- /dev/null +++ b/letsencrypt-win-simple/app.manifest @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/letsencrypt-win-simple/letsencrypt-win-simple.csproj b/letsencrypt-win-simple/letsencrypt-win-simple.csproj index 36736abaa..cbf3c13cd 100644 --- a/letsencrypt-win-simple/letsencrypt-win-simple.csproj +++ b/letsencrypt-win-simple/letsencrypt-win-simple.csproj @@ -31,6 +31,9 @@ prompt 4 + + app.manifest + ..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll @@ -68,6 +71,9 @@ + + Designer +