Godot Version
Godot-Stable-4.5.1
Question
I’m trying to use a self-signed certificate for a Secure WebSocket server on my local network. How can I use the certificate with Godot? I need it to be using WSS in order for some devices (such as many android devices) to connect.
1 Like
If Godot is your client you can specify unsafe TLS clients for the various websocket types, typically the second parameter
##### Direct web socket peer
var ws := WebSocketPeer.new()
var ws_tls_option := TLSOptions.client_unsafe() # only use for debug! should accept self-signed
var err := ws.connect_to_url(server_host, ws_tls_option)
if err != OK:
push_error("Failed to attempt connecting to web socket url, ", error_string(err))
##### High level multiplayer peer
var ws_peer := WebSocketMultiplayerPeer.new()
var ws_tls_option := TLSOptions.client_unsafe()
var err := ws_peer.create_client(server_host, ws_tls_option)
if err != OK:
push_error("Failed to attempt connecting to web socket url, ", error_string(err))
else:
multiplayer.multiplayer_peer = ws_peer
Thanks! You’re a lifesaver. On a related note, do you know any way to do something similar for HTTPS?
HTTPClient has TLS options on connect_to_host, 3rd agument
HTTPRequest has a method to set TLS options set_tls_options
That did the trick! Thank you!