Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a self-signed certificate with Safari and websockets (osx/ios)

Tags:

ssl

safari

I need to test secure websockets. I'd like to do it with a self signed certificate. So made quick web server in node following these instuctions.

Then I added a websocket server using the ws npm module.

So I go to try it in Chrome. Chrome complains when I first visit the https page that the cert is unverifiable (that's expected) but I hit "advanced" and "proceed" and it connects to the page and the websockets work and are secure.

So then I try it in Safari. It also complains the cert is unverifiable (expected) but I click "continue". It loads the HTTPS page but won't do the websockets. Both OSX Safari and iOS Safari show

WebSocket network error: OSStatus Error -9807: Invalid certificate chain 

Is there a way to use self signed certs with Safari? Specifically without adding the self-signed root cert to the OS?

like image 322
gman Avatar asked Apr 20 '16 11:04

gman


People also ask

How do I enable Websockets in Safari?

Scroll down and tap on “Safari” Scroll down to the bottom and tap on “Advanced” Tap on “Experimental Features” at the bottom. Scroll down until you see “NSURLSession WebSocket”

How do I add a self-signed certificate to trusted Iphone?

If you want to turn on SSL/TLS trust for that certificate, go to Settings > General > About > Certificate Trust Settings. Under "Enable full trust for root certificates," turn on trust for the certificate.


1 Answers

It seems that the situation has changed since you asked, because it does work on OSX Safari now after accepting the self-signed certificate (this will require entering your OSX admin password once).

For mobile, the only workaround that worked for me is not to use SSL at all (ws://).

I'm not sure whether Safari will accept mixed https:// + ws:// pages, but it's worth a try if you want to keep SSL for the http part.

I can't find the official Apple documentation that says that self-signed certificates won't be accepted for websockets, but every post out there seems to say so.

like image 105
Florent Thiery Avatar answered Sep 18 '22 11:09

Florent Thiery