Secure WebSocket (WSS) with https localhost SSL certificate?

I am a little familiar with all this WebSocket and SSL certificate.

So, I created my own WebSocket server on the Android side, and the website is the client. I was able to get it to work with regular WebSocket (ws://) , but not protected WebSocket (wss://) due to the fact that it requires an SSL certificate.

My question is, how can I get an SSL certificate? From what I read, the SSL certificate is domain based. I need this for localhost. I need this for something like this address:

 wss://localhost:8080/ws/main 

How can I get an SSL certificate that will work with localhost .

Thank you for your time!

======================== EDIT =========================>

The reason why I do this: I have a Bluetooth service in my Android app that will receive data from connected Bluetooth devices, such as Weight Scale and Blood Pressure machine. I already have this part, and I want to take this data and transfer it to the website. WebSocket seemed easier, because the user will have my application open, and when he makes his weight, he will automatically fill in the field on the website with the weight from the weight scale. I hope I will explain this clearly.

To do this, I need to have a way to transfer weight or blood pressure values ​​from Java (Android) to a website that loads in WebView. So I thought WebSocket would be the easiest way.

Please tell me if you think there is an easier way.

In addition, I have already tried a self-signed certificate and get the following error:

 I/X509Util: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 

OR

 Exception=javax.net.ssl.SSLException: Error occured in delegated task:javax.net.ssl.SSLException: Not trusted server certificate 

Thank!!!

+1
android ssl websocket
Mar 16 '16 at 13:45
source share
1 answer

We faced a similar problem, our solution was to register a subdomain in one of our domains with an A record up to 127.0.0.1 and get a certificate for this domain.

  • local.example.com -> Write to 127.0.0.1
  • SSL certificate requested for local.example.com

I am afraid that this answer is too late for you, it may be useful for others who find this article.

0
Oct 18 '16 at 11:31 on
source



All Articles