Sitecore Commerce InitializeEnvironment error: 'Failed to get connection for Sitecore'

After installing Sitecore Commerce 8.2.1 using the provided powershell scripts, the initialize environment command failed with the following error:

localhost:5000/commerceops/InitializeEnvironment(environment='HabitatAuthoring')

{
   "@odata.context":"http://localhost:5000/CommerceOps/$metadata#Commands/$entity",
   "@odata.type":"#Sitecore.Commerce.Core.Commands.InitializeEnvironmentCommand",
   "Id":"0279d5d989dc43249df9827354786a61",
   "ResponseCode":"Error",
   "Messages":[
      {
         "MessageDate":"2018-02-12T00:10:55.4189589Z",
         "Code":"Error",
         "Text":"Failed to get connection for Sitecore",
         "CommerceTermKey":"ConnectionError"
      }
   ],
   "Models":[

   ],
   "ActionUrl":null
}

Troubleshooting

Double checked all environment configs in 'CommerceEngine\wwwroot\data\Environments' to make sure that the sitecore username & password were correct. Check.

Inspected the IIS bindings for the site, and found that https was configured. Check.

Epiphany

Even though there was a binding for https, a certificate was not assigned. For some odd reason, the install-commerce-sites.ps1 script did not generate and attach an SSL certificate to the binding!

The Fix

Manually generated a self-signed certificate and updated the binding. Job done.

.
.
.
.
.
.
.
.
.
.

Still here?

How do you generate a self-signed certificate you ask...Take your pick ;)

MakeCert
Powershell