local-ip.co - DNS service for local IP addresses with SSL/HTTPS support
What is this about
In one of our projects we faced a problem, that we wanted to connect to websocket on a local network from webpage, that was served from the Internet. In order to use secure web socket connection (wss://) we needed the SSL certificate, but you can't get one for local IP's. The bottomline was that we could not change client machines configuration (no /etc/hosts, no importing of own CA's).
Looking for the solution we got inspired by the service xip.io which enables resolving domains to IP addresses in local network. It works like this:
dig 10.0.0.1.xip.io
;; ANSWER SECTION:
10.0.0.1.xip.io. 299 IN A 10.0.0.1
So we came up with the idea, that we could use wildcard SSL certificate and slightly change the xip.io's method to put the local IP without dots into the URL - to get the subdomain that is complaint with the wildcard SSL. So we started http://local-ip.co service, which works like this:
dig 10-0-0-1.my.local-ip.co
;; ANSWER SECTION:
10-0-0-1.my.local-ip.co. 299 IN A 10.0.0.1
SSL certificate for *.my.local-ip.co
The real good news is, you can get from us SSL certificate for domain *.my.local-ip.co
for free :) - here it comes:
- certificate: http://local-ip.co/cert/server.pem
- intermediate certificates http://local-ip.co/cert/chain.pem
- certificate key http://local-ip.co/cert/server.key
Example
Start secure node.js websocket server with the code below and visit https://127-0-0-1.my.local-ip.co:8443/
in your browser - you should see secure HTTPS connection to your local websocket server :)
'use strict';
const fs = require('fs');
const https = require('https');
const webSocketServer = require('ws').Server;
var certFile = fs.readFileSync('var/www/html/cert/server.pem');
var keyFile = fs.readFileSync('var/www/html/cert/server.key');
const httpsServer = https.createServer({
key: keyFile,
cert: certFile
});
const wss = new webSocketServer({
server: httpsServer
});
httpsServer.on('request', (req, res) => {
res.writeHead(200);
res.end('hello HTTPS world\n');
});
wss.on('connection', (ws) => {
ws.send('hello');
ws.on('message', (data) => {
ws.send('message received: ', data);
});
ws.on('close', () => {
console.log('socket closed');
});
});
httpsServer.listen(8443);
Disclaimer
This service comes without any guarantee and is provided as-is. We will do our best to keep it working, but we reserve the right to turn it off anytime and without any reason.
Contact
You can reach us via e-mail: admin [at] local-ip [dot] co