Skip to content

Commit

Permalink
Fixed Server 2008 cert store. Add email to registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan-Legend committed Dec 4, 2015
1 parent e9c5fce commit ec8c8fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions letsencrypt-win-simple/Plugin/IISPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public override void Install(Target target, string pfxFilename, X509Store store,
if (existingBinding != null)
{
Console.WriteLine($" Updating Existing https Binding");
existingBinding.CertificateHash = certificate.GetCertHash();
existingBinding.CertificateStoreName = store.Name;
existingBinding.CertificateHash = certificate.GetCertHash();
}
else
{
Expand All @@ -112,7 +112,7 @@ public override void Install(Target target, string pfxFilename, X509Store store,
iisBinding.SetAttributeValue("sslFlags", 1); // Enable SNI support
}

Console.WriteLine($" Commiting binding changes to IIS");
Console.WriteLine($" Committing binding changes to IIS");
iisManager.CommitChanges();
}
}
Expand Down
30 changes: 24 additions & 6 deletions letsencrypt-win-simple/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using ACMESharp.HTTP;
using ACMESharp.JOSE;
using ACMESharp.PKI;
using System.Security.Cryptography;

namespace LetsEncrypt.ACME.Simple
{
Expand Down Expand Up @@ -89,8 +90,18 @@ static void Main(string[] args)
}
else
{
Console.Write("Enter an email address (not public, used for renewal fail notices): ");
var email = Console.ReadLine().Trim();

var contacts = new string[] { };
if (!String.IsNullOrEmpty(email))
{
email = "mailto:" + email;
contacts = new string[] { email };
}

Console.WriteLine("Calling Register");
var registration = client.Register(new string[] { });
var registration = client.Register(contacts);

if (!Options.AcceptTOS && !Options.Renew)
{
Expand Down Expand Up @@ -261,11 +272,18 @@ public static void Auto(Target binding)

public static void InstallCertificate(Target binding, string pfxFilename, out X509Store store, out X509Certificate2 certificate)
{
Console.WriteLine($" Opening Certificate Store \"WebHosting\"");
store = new X509Store("WebHosting", StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
try
{
store = new X509Store("WebHosting", StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
}
catch (CryptographicException)
{
store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
}

Console.WriteLine($" Loading .pfx");
Console.WriteLine($" Opened Certificate Store \"{store.Name}\"");

// See http://paulstovell.com/blog/x509certificate2
certificate = new X509Certificate2(pfxFilename, "", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
Expand All @@ -288,7 +306,7 @@ public static string GetCertificate(Target binding)
var rsaKeys = cp.GeneratePrivateKey(rsaPkp);
var csrDetails = new CsrDetails
{
CommonName = dnsIdentifier
CommonName = dnsIdentifier,
};
var csrParams = new CsrParams
{
Expand Down
6 changes: 3 additions & 3 deletions letsencrypt-win-simple/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LetsEncrypt.ACME.CLI")]
[assembly: AssemblyTitle("Let's Encrypt Simple Windows Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Let's Encrypt")]
Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.7.*")]
[assembly: AssemblyFileVersion("1.7.0.0")]

1 comment on commit ec8c8fa

@Rouzax
Copy link

@Rouzax Rouzax commented on ec8c8fa Dec 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would I use the email registration?

Please sign in to comment.