Streamlit-webrtc error - "Unsupported key type" error in from_cryptography_key in python3.9/site-packages/OpenSSL/crypto.py file

Hi,
testing the webrtc component locally with the basic code:

from streamlit_webrtc import webrtc_streamer
webrtc_streamer(key=“example”)

it worked last week, but it stopped working today with the following error:


TypeError: Unsupported key type

Traceback:

File ".../lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script exec(code, module.__dict__)
File ".../streamlit-webrtc-main/pages/test_webrtc.py", line 37, in <module>
    webrtc_streamer(key="example", video_frame_callback=videoFilter)
File ".../lib/python3.9/site-packages/streamlit_webrtc/component.py", line 568, in webrtc_streamer
    webrtc_worker = WebRtcWorker(
File ".../lib/python3.9/site-packages/streamlit_webrtc/webrtc.py", line 375, in __init__
    self.pc = RTCPeerConnection()
File ".../lib/python3.9/site-packages/aiortc/rtcpeerconnection.py", line 294, in __init__
    self.__certificates = [RTCCertificate.generateCertificate()]
File ".../lib/python3.9/site-packages/aiortc/rtcdtlstransport.py", line 156, in generateCertificate
    key=crypto.PKey.from_cryptography_key(key),
File "..../lib/python3.9/site-packages/OpenSSL/crypto.py", line 274, in from_cryptography_key
    raise TypeError("Unsupported key type")

I have updated streamlit to version 1.19.0 and streamlit-webrtc to version 0.44.7. but i’m still facing the same issue. Please guide me on what to do in order to resolve this issue. Thank you.

Manage to get webrtc running in streamlit again. Not sure if this is the solution, @whitphx - but this works for now.

I found that my issue was related to an outdated version of pyOpenSSL -

current version was 23.0.0 and the version in my conda was 22.0.0 - so i had to update it - using pip didn’t work for me, so i used conda

conda install -c conda-forge pyopenssl

1 Like