title: How do we secure socket connections/messages to a local webserver?
body: <p>I am implementing a Local Websocket server in Express nodeJS. Data is sent from the front-end to the server by creating a <code>new WebSocket(ws://&lt;private_ip&gt;:3000);</code> as soon as <code>&lt;private_ip&gt;:3000</code> is opened in a phone browser. (notice the <strong>ws</strong>)</p>
  <p>This Local Websocket server will not be hosted on a public server but only on <strong>personal machines</strong> e.g. your own windows/mac machine. The reasoning behind this is not related to this post and will be omitted.</p>
  <p>I have a basic understanding of how certificates work. I know that <code>self-signed certificates</code> are usually imported to the browser to be trusted. The goal is to use something like <code>new WebSocket(wss://&lt;private_ip&gt;:3000);</code> at the client side (notice the <strong>wss</strong>).</p>
  <p>I fail to understand how the socket client created by code will trust a <code>self-signed certificate</code>, hence the question: is there a way to secure the connection/communication to/with a locally hosted Webserver</p>