preloader
心得

MacOS Monterey(12.1) Use Openssl3.0

MacOS Monterey(12.1) Use Openssl3.0

I had found following problem as I install packages of python on macOS Monterey(12.1) by using a third party script:

zipfile = ZipFile(StringIO(fp.read()))
  .pyenv/versions/2.7.18/lib/python2.7/socket.py", line 355, in read
  data = self._sock.recv(rbufsize)
  .pyenv/versions/2.7.18/lib/python2.7/ssl.py", line 754, in recv
  return self.read(buflen)
  .pyenv/versions/2.7.18/lib/python2.7/ssl.py", line 641, in read
  v = self._sslobj.read(len)
  ssl.SSLError: [SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:1946)
  • Briefly analysis for root-cause about this problem

    • This is because macOS upgrade openssl to version 3.0.0 after macOS upgrading itself from BigSur to Monterey.
  • Detail analysis for root-cause about this problem

    • Prior to version of openssl 1.1.1, it’s relaxation of judging eof-appearer scenario for openssl, which comparing 1.1.1. And 3.0.0 is a descendant version of 1.1.1 so it’s same or more strict one with 1.1.1. Starting from version 3.0.0, it provides option: OP_IGNORE_UNEXPECTED_EOF for setting to relax handling behavior same as 1.1.0 and 1.0.2 .
    • In addition, version 1.1.1 also provides option suppress_ragged_eofs = true for setting handling behavior back to version 1.0.2 .

 

 

  • Temporary workaround Currently, my workaround is to skip the problematic code, and then I can install python packages what I want successfully. In the future, formal solutions are listing below, and just take one of them:
    1. Set above mentioned options as python script using openssl
    2. Change python ZipFile package to other alternative one(s) has functionalities I want.

=====
在 macOS Monterey(12.1) 作業系統上,我用第三方腳本安裝 python 套件可能會遇到以下問題:

zipfile = ZipFile(StringIO(fp.read()))
  .pyenv/versions/2.7.18/lib/python2.7/socket.py", line 355, in read
  data = self._sock.recv(rbufsize)
  .pyenv/versions/2.7.18/lib/python2.7/ssl.py", line 754, in recv
  return self.read(buflen)
  .pyenv/versions/2.7.18/lib/python2.7/ssl.py", line 641, in read
  v = self._sslobj.read(len)
  ssl.SSLError: [SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:1946)
  • 問題原因概要分析

    • 這是 macOS 從 BigSur 升級到 macOS 12.1(Monterey) 後,macOS 自動升級 openssl 到 3.0.0 而產生的結果.
  • 問題原因詳細分析

    • openssl 1.1.1 版號之前的版本, 對於 eof 出現情境的判斷比較寬鬆,自 1.1.1 之後的出現情境與處理行為比較嚴格,而 3.0.0 是 1.1.1 之後的延續版本,所以也是一樣的嚴格或者更嚴格。3.0.0 版號開始額外提供設定選項 OP_IGNORE_UNEXPECTED_EOF ,設定此選項能夠放鬆其處理行為到版號 1.1.0 和 1.0.2 。
    • 另外,1.1.1 版號額外提供選項 suppress_ragged_eofs = true,讓 eof 處理行為回到 1.0.2 。

 

 

  • 暫行處理方式
    目前我的處理方式,是執行第三方腳本之前, 先遮蔽掉問題的程式碼, 這樣就能成功安裝套件。未來預期能從源頭解決的方式是以下其中之一:
    1. python 呼叫 openssl 時,看能不能設定上述選項.
    2. 換掉 python ZipFile 套件,改用其他套件是否能達到相同功能.