ssl.SSLError: [SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:3862)

Linux安装tidevice后,执行命令完整报错:

Traceback (most recent call last):
  File "/home/*****/.local/bin/tidevice", line 8, in 
    sys.exit(main())
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/__main__.py", line 777, in main
    actions[args.subparser](args)
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/__main__.py", line 286, in cmd_launch
    pid = d.instruments.app_launch(args.bundle_id,
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/_device.py", line 827, in instruments
    return self.connect_instruments()
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/_device.py", line 815, in connect_instruments
    if self.major_version() >= 14:
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/_device.py", line 967, in major_version
    version = self.get_value("ProductVersion")
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/_device.py", line 399, in get_value
    with self.create_session() as conn:
  File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/_device.py", line 351, in create_session
    s.switch_to_ssl(self.ssl_pemfile_path)
  File "/home/*****/.local/lib/python3.10/site-packages/tidevice/_safe_socket.py", line 90, in switch_to_ssl
    context.load_cert_chain(pemfile, keyfile=pemfile)
ssl.SSLError: [SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:3862)

解决办法:
打开这个脚本

sudo vim /home/*****/.local/lib/python3.10/site-packages/tidevice/_safe_socket.py

简单粗暴的修改代码:

# context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context = ssl.SSLContext()
context.set_ciphers('ALL:@SECLEVEL=0')

解决了openssl报错问题
参考:
https://github.com/alibaba/taobao-iphone-device/issues/64

你可能感兴趣的:(ssl.SSLError: [SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:3862))