How to create Python secure websocket client request?

后端 未结 4 515
半阙折子戏
半阙折子戏 2020-12-09 18:44

My Python secure websocket client code giving me exception as follows:

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

4条回答
  •  爱一瞬间的悲伤
    2020-12-09 19:43

    Only try the below for testing purposes only. The below is a highly insecure kluge:

    import asyncio, ssl, websockets
    
    #todo kluge
    #HIGHLY INSECURE
    ssl_context = ssl.SSLContext()
    ssl_context.check_hostname = False
    ssl_context.verify_mode = ssl.CERT_NONE
    #HIGHLY INSECURE
    #todo kluge
    
    uri = "wss://myAwesomeSSL.wss.kluge"
    
    async with websockets.connect(uri, ssl=ssl_context) as websocket:
            greeting = await websocket.recv()
            print(f"< {greeting}")
    

提交回复
热议问题