Certificates
APIEngine serves its API over HTTPS. On Windows, IIS presents the certificate bound to the site's HTTPS binding. On Linux, Apache terminates TLS in front of APIEngine and presents the certificate named in its vhost.
What APIEngine needs
| Requirement | Detail |
|---|---|
| Server certificate | Issued for each host name clients use, for example api.example.com. A wildcard certificate such as *.example.com covers one extra label: api.example.com, but not test.api.example.com |
| Private key | The certificate must be imported with its private key. Certificates without one are not offered by the installer and cannot be bound |
| Validity | Inside its valid-from and expiry dates |
| Trust | Issued by a certificate authority the clients trust. A self-signed certificate works only on computers that have been told to trust it |
| Store (Windows) | LocalMachine\My (Personal) or LocalMachine\WebHosting (Web Hosting) on the APIEngine server |
The application pool identity needs no access to the private key. IIS (http.sys) serves the certificate from the machine store.
Choosing a certificate during install (Windows)
The installer lists every usable certificate in LocalMachine\My and LocalMachine\WebHosting: one with a private key that is inside its validity dates. Each row shows the subject, store, issuer and expiry. Certificates that cover the host name entered for the site are listed first, trusted certificates before untrusted ones, then the latest expiry first. The default is the first trusted certificate that covers the host name.
| Answer | Result |
|---|---|
| A certificate number | The certificate is bound to the HTTPS binding from its own store |
| No certificate, then Yes to "Create a self-signed certificate for this host and bind it to https?" | A self-signed certificate is created and bound (see below) |
| No certificate, and No to the self-signed offer | No HTTPS binding is created. The installer prints No https binding was created - there is no certificate to bind to one. and the site answers only on the local HTTP port 127.0.0.1:8080 |
When another IIS site already uses the HTTPS port, the APIEngine binding shares the port with a host name and Server Name Indication (SNI), and its certificate is bound for that host name only.
After binding, the installer reads the binding back and checks that HTTPS answers. A failed TLS handshake is reported as a failed check at the end of the run, with the thumbprint and the fix.
Unattended installs
| Option | Result |
|---|---|
-CertThumbprint <thumbprint> | Binds that certificate. It is looked up in LocalMachine\My, then LocalMachine\WebHosting |
-Unattended with no -CertThumbprint | Binds the one trusted certificate covering the host name. With none, with several, or with no host name, a self-signed certificate is created and bound |
Self-signed certificate
The installer creates the certificate in LocalMachine\My with the friendly name APIEngine HTTPS (<site name>), valid for five years. It covers the site's host name, the server's computer name, its fully qualified name and localhost. The installer adds a copy to LocalMachine\Root on the APIEngine server, so a browser on the server opens the site without a warning. Running the installer again reuses that certificate while it is valid, and removes older ones it created for the same site.
A self-signed certificate suits testing and internal servers. Every client computer that calls APIEngine must trust it, otherwise the client refuses the connection or shows a certificate warning. To trust it on a client, export it on the server and import it into the client's Trusted Root store. On the APIEngine server:
On each client, from PowerShell as Administrator:
For servers that clients outside your network call, use a certificate from a public certificate authority.
Binding or changing the certificate after install (Windows)
Importing the certificate
Import the certificate, with its private key, into the Local Computer Personal store. From PowerShell as Administrator:
Import into LocalMachine (Local Computer). A certificate in the current user's store cannot be bound to an IIS site.
IIS Manager
- Open IIS Manager and select the site, for example
APIEngine-default. - Select Bindings in the Actions pane.
- Select the
httpsbinding and select Edit. If the site has nohttpsbinding, select Add and set Type tohttps, Port to443and Host name to the name clients use. - Tick Require Server Name Indication when another site on the server uses the same port.
- Pick the certificate in SSL certificate and select OK.
- Recycle the site's application pool.
IMAGE NEEDED - IIS Edit Site Binding dialog Shows: the Edit Site Binding dialog for an APIEngine site with Type https, Port 443, Host name api.example.com, Require Server Name Indication ticked and a certificate selected in SSL certificate Capture: IIS Manager, select the APIEngine site, Bindings, select the https row, Edit Crop: the dialog only, about 500x400 px
The local HTTP binding on 127.0.0.1:8080 needs no certificate. Leave it in place: it serves the checks below.
Re-running the installer
An upgrade asks Keep every current setting (quick install)?. Answer Y to keep the bound certificate. Answer N to walk through the HTTPS port, host name, local HTTP port and certificate: the certificate list opens with the current certificate as the default, and 0 keeps it. The installer rebinds the site and puts the old bindings back if the change fails. When the HTTPS port moves, the certificate entry on the old port is removed.
Command line check
The installer prints the thumbprint in its plan and in any failed certificate check. To see which certificate http.sys holds for the site, use the first form for a binding without a host name and the second for a binding with a host name and SNI:
Certificate Hash is the bound thumbprint and Certificate Store Name is MY or WebHosting. To bind a thumbprint from the command line when IIS Manager is not available:
appid takes any GUID; New-Guid generates one. Use certstorename=WebHosting for a certificate in the Web Hosting store. If an entry already exists for the address, remove it first with netsh http delete sslcert ipport=0.0.0.0:443 (or hostnameport=api.example.com:443).
Renewing or replacing a certificate (Windows)
- Import the new certificate, with its private key, into
LocalMachine\My. - Bind it to the site's
httpsbinding in IIS Manager (steps above), or re-run the installer and answerNto the quick-install question. - Recycle the site's application pool.
- Check from a client (below), then remove the old certificate from the store.
Certificates the installer created are not removed by the uninstaller. Remove them from LocalMachine\My and LocalMachine\Root by their friendly name APIEngine HTTPS (<site name>) when no longer needed.
Linux
APIEngine listens on plain HTTP on the loopback address only (127.0.0.1:5080 by default). Apache terminates TLS and forwards requests to it.
On a fresh install, install.sh writes the vhost <unit name>.conf (apiengine.conf by default) to /etc/apache2/sites-available on Debian and Ubuntu, or /etc/httpd/conf.d on Red Hat family systems. The vhost listens on port 443 and points at the system's self-signed placeholder certificate:
The installer warns that the placeholder must be replaced before serving traffic. It never changes certificates. An upgrade leaves an existing vhost as it is.
To bind the server's certificate, or to renew it:
- Copy the certificate and its private key to the server.
- Point
SSLCertificateFileandSSLCertificateKeyFilein the vhost at them. - Check the configuration with
apachectl -t(apache2ctl -ton Debian and Ubuntu). - Reload Apache:
systemctl reload apache2(Debian and Ubuntu) orsystemctl reload httpd.
Apache must have the ssl module enabled. The installer stops with exit code 13 when it is missing.
v95 and earlier
Certificate binding for the .NET Framework 4.8 line is covered on Installing v95 and earlier.
Checking HTTPS
| Where | Request | Healthy result |
|---|---|---|
| A client computer | https://api.example.com/api/v1/ping | {"result":true}, with no certificate warning |
| A client computer | https://api.example.com/api/v1/diagnostic/version | {"result":"<version>"} |
| The Windows server | http://127.0.0.1:8080/api/v1/ping | {"result":true} |
| The Linux server | http://127.0.0.1:5080/api/v1/ping | {"result":true} |
The loopback addresses answer on the server only and need no certificate, so they separate an APIEngine problem from a certificate problem. Ping calls the database and fails until the data server is saved on the Settings page; the version request answers before that.
For HTTPS errors after an install, see APIEngine will not start on Troubleshooting.