Supported cryptocurrencies:
BTC BTC
BCH Bitcoin Cash
NANO NANO
XTZ Tezos
0.0001 BTC
Englishbird's view at how to add encryption to websocket *implementation*, how integration with TLS library works

Artemciy 3 months ago
    Tags:


ylomat 3 months ago
https://crossbar.io/docs/Secure-WebSocket-and-HTTPS/
Mahdi 3 months ago
Depends on the kind of server you have.
but the easiest way is to use some kind of web-proxy like nginx.
let's imagine you can run your websocket server on localhost http port 8000.
all you need to do is to run https server with nginx on port 443 with a valid trusted ssl certificate. then you need to configure nginx to redirect all websocket requests incoming to this service(port 443 ssl) to your local port 8000. in this case nginx is a proxy server between client and your websocket server. connection between your web service and nginx is inside your server so it's safe, and the connection between client and nginx is based on trusted ssl over internet, which is safe too.
Rafael 3 months ago
Since the main focus of WAMP is web applications and the Internet of Things, clients are implemented in languages ​​that have proven themselves in these industries (only WAMP v2 clients are listed): The minimum requirement for building a WAMP client is the ability to use sockets and JSON serialization. Thus, many modern languages ​​already fulfill these requirements using standard libraries. Additional features that would add dependencies to the project, such as TLS encryption or MessagePack serialization, are optional.However, the persistence of WebSocket connections requires the use of blocking-protected libraries and asynchronous APIs. In languages ​​with one official mechanism like JavaScript, Erlang, or Go, this is not a problem. But languages ​​with several competing asynchronous programming solutions, such as Python or PHP, force the client author to commit to a specific part of the ecosystem.

For the same reason, integrating legacy projects can also take work. As an example, most of the popular Web Python frameworks that use WSGI, a synchronous API and run a WAMP client inside the WSGI worker need hand adapters like crochet. Routers
Although routers can be embedded directly into application code, and some client libraries also provide a router, this architecture is discouraged by the specification. [13]

Since the router is a moving part, it is best used as a replaceable black box, just like Apache or Nginx for HTTP:

Router Language
Crossbar.io Python (CPython and PyPy)
Erwa Erlang
Jawampa Java
Thruway PHP
wamp.rt JavaScript (Node.js only)
WampSharp C #
Wiola Lua
Nightlife-Rabbit JavaScript (Node.js only)
nexus go.WAMP is currently in version 2 [20], which introduces routed RPC. Version 1 is now obsolete. [21] At the moment, all routers are version 2 compatible. Some clients remain unported: Wamp.io, AutobahnAndroid and cljWAMP.

Version 2 of the specification is split into two parts: a baseline profile including Router RPC and Pub / Sub, and an advanced profile specifying trust levels, URI pattern matching, and client enumeration. The baseline profile is considered stable and implemented in current libraries while the extended profile is still evolving.
kimo2 2 months ago
1. change websocket protocol from "ws://" to "wss://" (websockets over tls) in your app, e.g.
const ws = new WebSocket('wss://example.com/some/path');
2. set up https on your webserver (a self-signed ssl certificate would be enough for testing)
3. configure your webserver to proxy websockets to your ws server (proxy_pass)

after this, you'll be able to use an encrypted data channel to send messages.
Larcah95 2 months ago Correct
http://www.aspl.es/nopoll/html/nopoll_core_library_manual.html#nopoll_implementing_mutual_auth
Artemciy 2 months ago
This describes the user API and not the implementation. But it might be closest to the mark so far.
trevaughn hamilton 2 months ago
You know that you can find all of these on Youtube right
shalini 2 months ago
This does not need any TLS library integration. We just need a webserver like apache where you need to configure WSS protocol.

1. First configure you webserver to support Secure Web socket (WSS) ex: webserver should allow wss://example.com:12345
2. Ex. How to configure apache web server for wss:
Add these two directives to webserver apache: ProxyPassMatch and ProxyPassReverse as shown below
<VirtualHost *:443>
.....
ProxyPassMatch ^/wss2/(.*) ws://exampl.com:12345/$1
ProxyPassReverse ^/wss2/(.*) ws://example.com:12345/$1
......
</VirtualHost>
3. After Step 2 changes on Apache webserver configuration, restart the server and connect to the WebSocket server using: wss://example.com:12345
4. With WSS protocol in place all transactions are encrypted on wire
Mohamad4900 2 months ago
Search in google
Wasabi 2 months ago
A well-structured webservice will do the trick.
Abose 2 months ago
You can help yourself with research, I could be of assistance.
Unique 87 2 months ago
Relies upon the sort of worker you have.

however, the least demanding path is to utilize some sort of web-intermediary like nginx.

how about we envision you can run your websocket worker on localhost http port 8000.

you should simply to run https worker with nginx on port 443 with a legitimate trusted ssl endorsement. at that point you need to arrange nginx to divert all websocket demands approaching to this service(port 443 ssl) to your nearby port 8000. for this situation nginx is an intermediary worker among customer and your websocket worker. association between your web administration and nginx is inside your worker so it's protected, and the association among customer and nginx depends on trusted ssl over web, which is protected as well.
Artemciy 2 months ago
I want to see how, given a plain websocket implementation, and a TLS library, we can combine the two in order to implement WSS.

If you can point me at a guide or a video that walks us through nginx implementation (source code) of WSS - that might be helpful.
Artemciy 2 months ago
For reference, here's a guide for implementing the plain websocket - http://siciarz.net/24-days-rust-nom-part-2/. What we need is a guide on doing the next step and applying the TLS.
Devender Singh 2 months ago
I have no idea.
Uğur 2 months ago
Mükemmel birşey
Siyambonga Jubeju 2 months ago
Socket.IO is easy to use and great for real-time communication between apps, but correctly configuring a cloud server to use a secure SSL-encrypted connection without performance degradation can be tricky. If you’ve run into such performance issues, messed with Apache configuration and proxying ports for Socket.IO handshakes and WebSocket traffic, or tried to get Let’s Encrypt to actually auto-renew properly so you’re not logging in every three months to manually run your renew script, then you’re in luck because you’ve finally found the guide that will actually work, written by someone who’s been there. Making sure WebSocket connections to backends are both securely encrypted over WSS and fast shouldn’t have to be so frustrating.

For this guide, we’ll use the following technologies (but you can use whichever platform or service you prefer):

Cloud: AWS Amazon Lightsail
Domain: Namecheap
SSL: Let’s Encrypt
The Socket.IO web app sample used in this guide is available on GitHub at https://www.github.com/instafluff/SecureWebSockets. For a brief explanation of the code, see the "More on the Code" section at the end of the article.

Why WebSockets and Socket.IO?
Socket.IO is a real-time, event-based messaging library that’s much faster than normal API calls done over the network using HTTP. If HTTP requests are like snail mail, WebSockets are like phone calls, which means they’re ideal for games, news and stock tickers, and other low-latency/fast-network scenarios. Socket.IO is one of the most popular libraries out there, making it simple to establish this communication channel between apps.

So why not use it all the time? WebSockets maintains the connection between you and the server, so it’s more CPU- and network-intensive, and therefore more costly to scale.

Performance Concerns
When running on an HTTP server like Apache or Nginx, it’s possible to proxy the WebSocket traffic to your Node server, but that dramatically slows your server’s ability to handle socket connections. Instead, your web app should connect directly to your backend to be able to handle as many users as possible.

Setting Up Your Cloud
In this guide we’ll use a custom domain with a Linux-based instance in Amazon Lightsail. So create your domain (I used Namecheap), then create an AWS account if you haven’t already at https://aws.amazon.com/lightsail/. Then log in to the Lightsail dashboard at https://lightsail.aws.amazon.com/ls/webapp/home/resources and create an instance:


Select Linux for the instance image and Node.js for the blueprint. You can use the defaults for the remaining options.


To get the first month free, select the lowest price plan, then name your instance and click Create instance:


After a few minutes, your server will be ready.

Next, we’ll direct the custom domain to our Lightsail instance. First, log into your registrar and get to the DNS settings:


Copy the IP address of your Lightsail instance, add an A Record entry to your custom domain, and set a subdomain—mine is socketexample.instafluff.tv.


Make sure the domain/subdomain correctly points to your new instance by opening up your domain in a web browser. This can take anywhere between a few minutes to (hopefully not) a whole day.

Securing Your Server with SSL Certs
The next step is to generate an SSL certificate using Let’s Encrypt. First, connect to your Lightsail instance to get a terminal window:



Now install the Let’s Encrypt certbot by running the following commands:

sudo apt-get update`
sudo add-apt-repository ppa:certbot/certbot`
sudo apt-get update`
sudo apt-get install certbot`

To get a certificate for our custom domain, we’ll take advantage of Apache, which is already set up on this image, then turn it off. First, install the Apache certbot plugin:

`sudo apt-get install python-certbot-apache`
Then create a symlink for apache2ctl to apachectl:

`sudo ln -s /opt/bitnami/apache2/bin/apachectl /opt/bitnami/apache2/bin/apache2ctl`
Now run `sudo certbot –apache` and enter your email and your custom domain without the www or http (for example, socketexample.instafluff.tv). When you’re asked to choose whether to redirect HTTP traffic, select 1: No redirect as we won’t be using Apache for our server.




When you’re done, disable Apache for good using the following commands (which apply only to Bitnami images):

`sudo /opt/bitnami/ctlscript.sh stop apache`
`sudo mv /opt/bitnami/apache2/scripts/ctl.sh /opt/bitnami/apache2/scripts/ctl.sh.disabled`

Installing Your Web App
We’re ready to run the sample server application. To do this, clone the sample code repository and install the dependencies, by running the following commands:

`git clone https://www.github.com/instafluff/SecureWebSockets.git`
`cd SecureWebSockets`
`npm install`

Next, create a .env file by opening the nano editor with `nano .env`. Add the following lines, then save by pressing Ctrl+O.

`PORT=443`
`DOMAIN=your.customdomain.com`
`CERTIFICATE=/etc/letsencrypt/live/your.customdomain.com/cert.pem`
`PRIVATEKEY=/etc/letsencrypt/live/your.customdomain.com/privkey.pem`
`CERTCHAIN=/etc/letsencrypt/live/your.customdomain.com/chain.pem`

Finally, test run the app using `sudo node index.js`. Then open "https://your.customdomain.com" in your computer’s web browser. If all went well, you should see a page with a numbered button that counts up as you click:


Bonus: Run Your App Worry-Free with a Process Manager
To finish up, let’s dot our i’s and cross our t’s to make sure our server requires only minimal maintenance. We’ll use the Forever command-line tool to run the Node server in the background so we can log off the console with the site still running. Run the following commands:

`sudo npm install -g forever`
`sudo forever start index.js`
If you need to restart the app, run:

`sudo forever restartall`

To keep your server running for longer than three months without having to think about it, follow these steps to automatically renew your Let’s Encrypt certificates:

Add a scheduled task to your crontab file by running `sudo crontab -e` with nano.
Add the following line to the bottom of the file:
0 0 * * * /usr/bin/certbot renew –pre-hook "sudo forever stopall" –post-hook "sudo /opt/bitnami/apache2/bin/apache2ctl stop && sudo forever start –sourceDir /home/bitnami/SecureWebSockets index.js"

Press Ctrl+O and Ctrl+X to save the file and exit.
This task will run every day at midnight and, when your certificate is up for renewal, the hooks will stop your server, renew with Let’s Encrypt using the Apache plugin, stop Apache, and, finally, restart your server.