【问题标题】:Does Autobahn|Python[asyncio] support secure websockets?Autobahn|Python[asyncio] 是否支持安全的 websocket?
【发布时间】:2019-03-27 14:12:34
【问题描述】:

Autobahn|Python 的 asyncio 变体是否支持安全的 WebSockets?有关使用 AutoBahn|Python 的安全 WebSockets 的文档仅给出了一个 Twisted 示例:https://autobahn.readthedocs.io/en/latest/websocket/examples.html#secure-websocket

【问题讨论】:

    标签: python autobahn


    【解决方案1】:

    确实有效。这是一个带有安全 websocket 的 asyncio 组件示例:

    import ssl
    from autobahn.asyncio.component import Component
    
    
    ssl_c = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
    ssl_c.load_verify_locations(cafile='my_ssl_key.pem')
    
    Component(
        transports={
                'type': 'websocket',
                'url': u'wss://127.0.0.1:8081/',
                'endpoint': {
                    'type': 'tcp',
                    'host': host,
                    'port': 8081,
                    'tls': ssl_c
                }
        },
        realm=u'realm1'
    )
    
    

    【讨论】:

      猜你喜欢
      • 2011-10-04
      • 2012-06-13
      • 1970-01-01
      • 1970-01-01
      • 2012-07-30
      • 2018-07-24
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多