Securing a private IP address (https certificate)

An SSL certificate cannot be issued for Reserved IP addresses (RFC 1918 and RFC 4193 range)/ private IP addresses (IPv4, IPv6), Intranet for Internal Server Name, local server name with a non-public domain name suffix.

You could however use a 'self-signed' certificate. Here's how to create one:

Creating a Self-signed Certificate for a private IP (example https://192.168.0.1) :

  1. You need OpenSSL installed. For example, on Ubuntu, you could install it by: sudo apt-get install openssl (It may already be installed. Type "openssl version" to find out) For Windows, you could try this: https://slproweb.com/products/Win32OpenSSL.html

  2. Once OpenSSL is installed, go to OpenSSL prompt by entering 'openssl' on the console (LINUX), or the cmd prompt (WINDOWS).

    $ openssl

    OpenSSL>

  3. Now do the following steps to create: Private key, Certificate Request, Self-signing the certificate, and putting it all together, by using the below commands:

i) Create KEY called mydomain.key:

OpenSSL> genrsa -out mydomain.key 2048

ii) Use the key to create a Certificate request called mydomain.csr You could accept the default options, or specify your own information:

OpenSSL> req -new -key mydomain.key -out mydomain.csr

iii) use the above to create a certificate:

OpenSSL> x509 -req -days 1825 -in mydomain.csr -signkey mydomain.key -out mydomain.crt

iv) Put all the above to create a PEM certificate: exit OpenSSL (OpenSSL> q) and go to certificate location and do:

$ sudo cat mydomain.key mydomain.crt >> mylabs.com.pem

mylabs.com.pem is your self-signed certificate. You can use this in requests like https://192.168.0.1 if your server supports https. Remember to check the port number for https(443).


Is it possible to obtain a certificate for a private IP address ?

A certificate can be bound to an IP address (see this). You can issue a self-signed certificate to a private address, but a trusted CA will not issue a certificate to a private address because it can not verify its identity.

For example a certificate issued to 192.168.0.1 would be theoretically valid in any context, and this should not be allowed by a trusted CA

Plex solves the problem with a Dynamic DNS and a wildcard certificate. The connection are done using the name (not the IP) of the device which is resolved to the private IP

Does a http header exists that allows insecure connections to a specific URL ? (like CORS for cross domain)

No, it does not exist. The browser blocks your XHR connections because they are HTTP connections initiated from a HTTPS page (mixed-content warning). Non-secure content can theoretically be read or modified by attackers, even though the parent page is served over HTTPs, so is normal and recommended that the browser warns the user.

To fix the mixed-content and https errors, you could serve the content through HTTPS and a self-signed certificate, and request users to import your root CA at browser.