Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    SSL TLSV1_ALERT_PROTOCOL_VERSION Error on Mac

    Cinema 4D SDK
    r19 python macos
    2
    3
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User
      last edited by A Former User

      Hello,
      I'm working on licensing for R19 and I'm getting an SSL error on Mac. The code works with Mac on R20 and greater. I've been working with @m_adam 's code from urllib2.urlopen fails on C4D for Mac. If I use https://www.google.com as the URL, I get HTML as a response, but not when using the POST method to my online store's API: https://api.gumroad.com/v2/licenses/verify (I'm also adding 'params' to this URL).

      req = urllib2.Request(url,urlencode(params))
      f = os.path.join(os.path.dirname(c4d.storage.GeGetStartupApplication()), "resource", "ssl", "cacert.pem")
      dataString = urllib2.urlopen(req, cafile=f).read()
      

      Result:

      Traceback (most recent call last):
        File "/Applications/MAXON/Cinema 4D R19/resource/modules/python/Python.osx.framework/lib/python2.7/urllib2.py", line 154, in urlopen
          return opener.open(url, data, timeout)
        File "/Applications/MAXON/Cinema 4D R19/resource/modules/python/Python.osx.framework/lib/python2.7/urllib2.py", line 431, in open
          response = self._open(req, data)
        File "/Applications/MAXON/Cinema 4D R19/resource/modules/python/Python.osx.framework/lib/python2.7/urllib2.py", line 449, in _open
          '_open', req)
        File "/Applications/MAXON/Cinema 4D R19/resource/modules/python/Python.osx.framework/lib/python2.7/urllib2.py", line 409, in _call_chain
          result = func(*args)
        File "/Applications/MAXON/Cinema 4D R19/resource/modules/python/Python.osx.framework/lib/python2.7/urllib2.py", line 1240, in https_open
          context=self._context)
        File "/Applications/MAXON/Cinema 4D R19/resource/modules/python/Python.osx.framework/lib/python2.7/urllib2.py", line 1197, in do_open
          raise URLError(err)
      urllib2.URLError: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:581)>
      

      I've spent hours trying to fix this but haven't gotten anywhere. I've also tried using urllib.urlopen, but I got the same TLSV1_ALERT_PROTOCOL_VERSION URLError.

      context = ssl.create_default_context(cafile=f)
      urllib.urlopen(req,context=context)
      

      I've tried to find an online API to fully replicate this issue in a script, but most do not allow to POST without a key. The rest of my code works with R18 and higher so this is my last step before launching.

      Can anyone from Maxon tell me what changed with the SSL or C4D's Python between R19 & R20 that might have caused this issue? Is there any way to fix it?

      Thank you!

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hi unfortunately it's most likely that the SSL version used in R19 is not anymore compatible with the certificate used to validate the connection from you and the website.

        So I don't see a real way to support it without investing a lot of time and unfortunately, we don't support R19 anymore so in this case, the most correct fix will be to update the SSL module which will not happen.
        You can give it a try to ssl.SSLError: tlsv1 alert protocol version or either use another networking library that uses its own SSL.
        Finally you may take a look to compile SSL yourself and incorporate it see Building NumPy for Cinema 4D on Windows and you can try its updated version of SSL https://public.niklasrosenstein.com/cinema4d/python/modules/ssl/

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @m_adam
          last edited by

          @m_adam Thank you, Maxime! Have a good weekend.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post