We have an ASP.NET MVC5 application that requires two certificates:
- An X509 elliptic curve certificate and it's corresponding private key (*.PFX)
- An X509 elliptic curve certificate (*.CER)
to be available in the Windows Server 2012 R2's Certificate Store ("Local Machine" account, "Personal" store). To clarify, these certificates are used by the MVC5 app's code and have nothing to do with SSL/TLS/HTTPS.
Question: How can I configure AWS Elastic Beanstalk, so that after deploying the MVC5 app, it already has those certificates and private keys in the certificate store? AWS has configured the EC2 Windows Servers auto-provisioned via Elastic Beanstalk such that the ASP.NET apps run in IIS under the IIS_IUSR
user permission, so we also would need to give IIS_IUSR
permission to access the certificate private key. I'm not clear if IIS_IUSR is actually follows the principle of least-privilege or if I'm granting the wrong account the permission - but it does work (see below). We are currently deploying via AWS Toolkit for Visual Studio 2013 but are open to other deployment techniques if that helps the main problem.
Currently, we have an ugly, manual workaround which is
- remote into each instance, and in each instance do the following
- upload the certificate files (*cer and *pfx)
- manually run a batch file to load them into the cert stores (also have to add them to the Root store since they are self-signed certificates). The batch file looks like
certutil -f -addstore Root OurCert-SS.cer // just a CER version of the PFX below certutil -f -addstore Root RemoteCert-SS.cer certutil -f -p test -importPFX MY OurCert-SS.pfx certutil -f -addstore MY RemoteCert-SS.cer
- Manually Open MMC => Certificates (Local Machine) => Give
IIS_IUSRS
theFull control
permission for the certificate's private key (otherwise the ASP.NET app can't get the private key). Details in this post
Obviously this vastly kills the abstraction PaaS is supposed to provide because anytime instances scale or get recycled, we have to do the above :( ... so would appreciate any help on this.