SSL module initialization error on Fedora Linux #114452

Closed
opened 2023-11-03 12:16:39 +01:00 by Alexander Kovelenov · 6 comments

System Information
Operating system: Fedora Linux 38
Graphics card: Nvidia GTX 1650

Blender Version
Broken: Blender 4.0 b27ff093ca
Worked: Blender 4.0 e9ad267151

Running request.urlopen() causes ssl.SSLError

Exact steps for others to reproduce the error

Run Blender, open Python Console, run the following code:

import urllib
from urllib import request
print(request.urlopen('https://blender.org').status)

It will print the crash backtrace (instead of status 200):

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 1317, in do_open
    h = http_class(host, timeout=req.timeout, **http_conn_args)
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/http/client.py", line 1422, in __init__
    context = ssl._create_default_https_context()
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/ssl.py", line 757, in create_default_context
    context = SSLContext(PROTOCOL_TLS_CLIENT)
  File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/ssl.py", line 496, in __new__
    self = _SSLContext.__new__(cls, protocol)
ssl.SSLError: [CONF: MODULE_INITIALIZATION_ERROR] module initialization error (_ssl.c:3093)

The code:

import ssl
print(ssl.get_default_verify_paths())

prints:

DefaultVerifyPaths(cafile='/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/site-packages/certifi/cacert.pem', capath='/etc/ssl/certs', openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/etc/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/etc/ssl/certs')

The code:

import os
print(os.environ.get("SSL_CERT_FILE"))

prints:

/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/site-packages/certifi/cacert.pem

The issue started to reproduce after Blender 4.0 Beta build b27ff093ca. The last version that worked was Blender 4.0 Beta e9ad267151.

The issue also causes Verge3D plugin to crash since it uses python-based Tornado server running on localhost.

**System Information** Operating system: Fedora Linux 38 Graphics card: Nvidia GTX 1650 **Blender Version** Broken: Blender 4.0 b27ff093caa0 Worked: Blender 4.0 e9ad267151c9 **Running request.urlopen() causes ssl.SSLError** **Exact steps for others to reproduce the error** Run Blender, open Python Console, run the following code: ``` import urllib from urllib import request print(request.urlopen('https://blender.org').status) ``` It will print the crash backtrace (instead of status 200): ``` Traceback (most recent call last): File "<blender_console>", line 1, in <module> File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 216, in urlopen return opener.open(url, data, timeout) File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 519, in open response = self._open(req, data) File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 536, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 496, in _call_chain result = func(*args) File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 1391, in https_open return self.do_open(http.client.HTTPSConnection, req, File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/urllib/request.py", line 1317, in do_open h = http_class(host, timeout=req.timeout, **http_conn_args) File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/http/client.py", line 1422, in __init__ context = ssl._create_default_https_context() File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/ssl.py", line 757, in create_default_context context = SSLContext(PROTOCOL_TLS_CLIENT) File "/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/ssl.py", line 496, in __new__ self = _SSLContext.__new__(cls, protocol) ssl.SSLError: [CONF: MODULE_INITIALIZATION_ERROR] module initialization error (_ssl.c:3093) ``` The code: ``` import ssl print(ssl.get_default_verify_paths()) ``` prints: ``` DefaultVerifyPaths(cafile='/home/alex/apps/blender-4.0/4.0/python/lib/python3.10/site-packages/certifi/cacert.pem', capath='/etc/ssl/certs', openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/etc/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/etc/ssl/certs') ``` The code: ``` import os print(os.environ.get("SSL_CERT_FILE")) ``` prints: ``` /home/alex/apps/blender-4.0/4.0/python/lib/python3.10/site-packages/certifi/cacert.pem ``` The issue started to reproduce after Blender 4.0 Beta build b27ff093caa0. The last version that worked was Blender 4.0 Beta e9ad267151c9. The issue also causes Verge3D plugin to crash since it uses python-based Tornado server running on localhost.
Alexander Kovelenov added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-11-03 12:16:40 +01:00

Checked Ubuntu 22.04, appears to be working just fine.

Checked Ubuntu 22.04, appears to be working just fine.

Strange thing, once the crash happens, the second exec:

print(request.urlopen('https://blender.org').status)

Won't crash, and prints 200.

Strange thing, once the crash happens, the second exec: ``` print(request.urlopen('https://blender.org').status) ``` Won't crash, and prints 200.

Another strange thing, Blender 3.6 causes different kind of crash (CERTIFICATE_VERIFY_FAILED instead of MODULE_INITIALIZATION_ERROR), though Verge3D works on that version just fine:

Traceback (most recent call last):
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1283, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1329, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1278, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1038, in _send_output
    self.send(msg)
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 976, in send
    self.connect()
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1455, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)
Another strange thing, Blender 3.6 causes different kind of crash (CERTIFICATE_VERIFY_FAILED instead of MODULE_INITIALIZATION_ERROR), though Verge3D works on that version just fine: ``` Traceback (most recent call last): File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/urllib/request.py", line 1348, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1283, in request self._send_request(method, url, body, headers, encode_chunked) File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1329, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1278, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1038, in _send_output self.send(msg) File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 976, in send self.connect() File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/http/client.py", line 1455, in connect self.sock = self._context.wrap_socket(self.sock, File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/ssl.py", line 513, in wrap_socket return self.sslsocket_class._create( File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/ssl.py", line 1071, in _create self.do_handshake() File "/home/alex/apps/blender-3.6/3.6/python/lib/python3.10/ssl.py", line 1342, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007) ```
Campbell Barton changed title from SSL module initialization error on Linux to SSL module initialization error on Fedora Linux 2023-11-04 05:03:55 +01:00

The problem is /etc/ssl/openssl.cnf on Fedora38 isn't compatible with the OpenSSL distributed by Blender - at least, the configuration fails to load. Replacing the /etc/ssl/openssl.cnf with the file from ArchLinux lets Blender load.

So from what I can see Blender shouldn't use /etc/ssl/ - since we can't guarantee the files here will be compatible with Blender's SSL. Submitted PR !114569.

For a short term workaround set OPENSSL_CONF=/dev/null which prevents the incompatible configuration being used.

The problem is `/etc/ssl/openssl.cnf` on Fedora38 isn't compatible with the OpenSSL distributed by Blender - at least, the configuration fails to load. Replacing the `/etc/ssl/openssl.cnf` with the file from ArchLinux lets Blender load. So from what I can see Blender shouldn't use `/etc/ssl/` - since we can't guarantee the files here will be compatible with Blender's SSL. Submitted PR !114569. For a short term workaround set `OPENSSL_CONF=/dev/null` which prevents the incompatible configuration being used.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-11-07 13:26:55 +01:00

Update, the new libraries are now in SVN so new builds should not suffer from this problem.

Update, the new libraries are now in SVN so new builds should not suffer from this problem.

Confirmed, both 4.0 and 4.1 nightlies work fine. Thank you Campbell!

Confirmed, both 4.0 and 4.1 nightlies work fine. Thank you Campbell!
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#114452
No description provided.