Fixing PlayOnMac Wine Manager


Categories:

The latest release of PlayOnMac 4.4.3 does not allow viewing Wine packages, due to missing Certificate Authority verification.

% ./playonmac
[main] Message: PlayOnMac (4.4.3) is starting
[clean_tmp] Message: Cleaning temp directory
[install_plugins] Message: Checking plugin: ScreenCap...
[update_check] Message: List is up to date
Donwloading https://phoenicis.playonlinux.com/index.php/wine?os=darwin
Traceback (most recent call last):
  File "urllib/request.pyc", line 1350, in do_open
  File "http/client.pyc", line 1240, in request
  File "http/client.pyc", line 1286, in _send_request
  File "http/client.pyc", line 1235, in endheaders
  File "http/client.pyc", line 1006, in _send_output
  File "http/client.pyc", line 946, in send
  File "http/client.pyc", line 1409, in connect
  File "ssl.pyc", line 500, in wrap_socket
  File "ssl.pyc", line 1040, in _create
  File "ssl.pyc", line 1309, in do_handshake
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/PlayOnMac.app/Contents/Resources/playonlinux/python/wine_versions/WineVersionsFetcher.py", line 24, in _sync_fetch_all_available_wine_versions
  File "urllib/request.pyc", line 222, in urlopen
  File "urllib/request.pyc", line 525, in open
  File "urllib/request.pyc", line 542, in _open
  File "urllib/request.pyc", line 502, in _call_chain
  File "urllib/request.pyc", line 1393, in https_open
  File "urllib/request.pyc", line 1353, in do_open
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>

The error results in the Wine Version UI not updating:

The Fix

A quick fix is to modify the functions that handle downloading the wine versions, which is WineVersionsFetcher.py:

Note: I have updated this file here so that if it is added to the main repo, we do not break Linux compatibility.

diff --git a/python/wine_versions/WineVersionsFetcher.py b/python/wine_versions/WineVersionsFetcher.py
index fd758798..5f57aa45 100644
--- a/python/wine_versions/WineVersionsFetcher.py
+++ b/python/wine_versions/WineVersionsFetcher.py
@@ -18,10 +18,13 @@ class WineVersionFetcher():

     def _sync_fetch_all_available_wine_versions(self, callback, error):
         wine_version_url = "https://phoenicis.playonlinux.com/index.php/wine?os=%s" % self.operating_system
-        print("Donwloading %s " % wine_version_url)
+        print("Downloading %s " % wine_version_url)
         try:
             request = urllib.request.Request(wine_version_url, None, {'User-Agent': Variables.userAgent})
-            handle = urllib.request.urlopen(request, timeout=5)
+            if self.operating_system == 'darwin':
+                handle = urllib.request.urlopen(request, cafile='../../lib/python3.8/certifi/cacert.pem', timeout=5)
+            else:
+                handle = urllib.request.urlopen(request, timeout=5)
             callback(self._convert_phoenicis_wine_versions_to_v4(json.load(handle)))
         except Exception as e:
             error(traceback.format_exc())

The above block can be copied into a patch file and ran:

cp WineVersionFetcher.py.orig WineVersionsFetcher.py
temp % patch -p3 < pol4_winemanager_patch.patch
patching file WineVersionsFetcher.py

Now we are able to download WINE!

Enjoy your games!

-Nrezinorn

Leave a Reply