Reputation: 4656
I am a little new to this whole WebSocket and SSL certificate thing.
So I have created my own WebSocket server on Android side and the website is the client. I was able to make it work with regular WebSocket (ws://)
, but not secure WebSocket (wss://)
due to the fact that it requires an SSL certificate.
How can I get a SSL certificate? From what I've read, an SSL certificate is based on a domain. I need it for localhost. I need it for something like this address:
wss://localhost:8080/ws/main
How can I go about getting an SSL certificate that will work with localhost
?
The reason why I am doing this: I have a Bluetooth service in my Android application that will be getting data from connected health Bluetooth devices like a weight scale and blood pressure machine. I have this part implemented already and I want to take this data and pass it to a website. WebSocket seemed easier, because the user will have my application open and when they do their weight, it would automatically fill the field on the website with the weight from the weight scale. I hope I am making this clear.
To do this, I need to have a way to pass the weight or blood pressure values from Java (Android) to the website that loads within a WebView. So I thought WebSocket would the easiest way.
Do you think there is an easier way?
Also, I've already tried a self-signed certificate, and I got 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 occurred in delegated task:javax.net.ssl.SSLException: Not trusted server certificate
Upvotes: 3
Views: 6023
Reputation: 408
We faced a similar problem. Our solution was to register a subdomain to one of our domains with an A record to 127.0.0.1 and get a certificate for that domain.
Upvotes: 1