Hi all,
i’m using:
Requirement already satisfied: robotframework-websocketclient in /usr/local/lib/python3.10/dist-packages (1.3.0)
Requirement already satisfied: robotframework in /usr/local/lib/python3.10/dist-packages (from robotframework-websocketclient) (6.0.2)
Requirement already satisfied: websocket-client in /usr/local/lib/python3.10/dist-packages (from robotframework-websocketclient) (1.6.1)
And i have problems to create a connection to a unsecure local server. I get a typical ssl-error:
SLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1007)
I know almost everything about this and i also know the solution about sending the option:
sslopt={“cert_reqs”: ssl.CERT_NONE}
So my problem is that i don’t know why this code is not working:
Library WebSocketClient
${auth}= Create Dictionary X-KVMD-User=blah X-KVMD-Passwd=blub
${ssl_opt}= Set Variable sslopt={“cert_reqs”: ssl.CERT_NONE}
${my_websocket}= WebSocketClient.connect wss://x.x.x.x/api/ws header=${auth} sslopt=${ssl_opt}
If you look in the keywords of WebSocketClient.connect then you see this:
from websocket import create_connection
class WebSocketClientKeywords:
def connect(self, URL, timeout=None, **options):
return create_connection(URL, timeout, **options)
So beside the URL i have to provide the header (as my server require auth-headers) and also the sslopt to accept self signed certs. But my code above does not work - it looks like i do not pass the sslopt correctly to the connect method. - I don’t know whats wrong there.
BUT i found a solution which is the following. I have added this small python code:
import ssl
import websocket
def open_ws_pikvm(uri, header, sslopt=None):
if sslopt is None:
sslopt = {“cert_reqs”: ssl.CERT_NONE}
ws = websocket.create_connection(uri, header=header, sslopt=sslopt)
return ws
And in RF i do this:
Library WebSocketClient
Library rfws.py
${auth}= Create Dictionary X-KVMD-User=blah X-KVMD-Passwd=blub
${ssl_opt}= Set Variable sslopt={“cert_reqs”: ssl.CERT_NONE}
${my_websocket}= rfws.open_ws_pikvm wss://${PIKVM}/api/ws header=${auth}
As you can see now i’m calling the open_ws_pikvm function from the python code above and now i do not pass the sslopt as this is already in the python code.
Doing so everything is working fine!.
So what’s wrong here.
So this code does not work:
${auth}= Create Dictionary X-KVMD-User=blah X-KVMD-Passwd=blub
${ssl_opt}= Set Variable sslopt={“cert_reqs”: ssl.CERT_NONE}
${my_websocket}= WebSocketClient.connect wss://x.x.x.x/api/ws header=${auth} sslopt=${ssl_opt}
Where this code does:
${auth}= Create Dictionary X-KVMD-User=blah X-KVMD-Passwd=blub
${ssl_opt}= Set Variable sslopt={“cert_reqs”: ssl.CERT_NONE}
${my_websocket}= rfws.open_ws_pikvm wss://${PIKVM}/api/ws header=${auth}
Could it be that the create_connection from RF WebSockerClient library is not working fine?
Has anyone worked with this Library?