Title: Cannot save SVG file with FIPS compliant Python · Issue #18192 · matplotlib/matplotlib · GitHub
Open Graph Title: Cannot save SVG file with FIPS compliant Python · Issue #18192 · matplotlib/matplotlib
X Title: Cannot save SVG file with FIPS compliant Python · Issue #18192 · matplotlib/matplotlib
Description: Bug report Bug summary If you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot use plt.savefig to save an image in SVG format. This is because the RenderSVG._make_id method takes the first 1...
Open Graph Description: Bug report Bug summary If you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot use plt.savefig to save an image in SVG format. This is because the Ren...
X Description: Bug report Bug summary If you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot use plt.savefig to save an image in SVG format. This is because the Ren...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/18192
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot save SVG file with FIPS compliant Python","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nIf you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot use `plt.savefig` to save an image in SVG format. This is because the `RenderSVG._make_id` method takes the first 10 characters of a `hashlib.md5` digest of entries in the SVG as the ID for that part of the SVG file. The MD5 algorithm is disabled on FIPS compliant systems or in FIPS compliant Python installs.\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\nThe big requirement here is a FIPS compliant system or at least a Python install compiled to be FIPS compliant. Then the following code will reproduce the error.\r\n\r\nTo reproduce, \r\n1. I started a CentOS 8 virtual machine\r\n2. Ran `sudo fips-mode-setup --enable \u0026\u0026 sudo reboot`\r\n3. After the reboot I confirmed FIPS mode had been enabled by running `fips-mode-setup --check` and it returned `FIPS mode is enabled.`.\r\n4. `sudo dnf install python3`\r\n5. `python3 -m venv venv`\r\n6. `./venv/bin/python -m pip install -U pip setuptools`\r\n7. `./venv/bin/python -m pip install matplotlib`\r\n8. `./venv/bin/python demo.py`. The contents of `demo.py` are listed below.\r\n\r\n```python\r\n\"\"\" demo.py: demonstrates that matplotlib can't save SVGs if FIPS mode enabled \"\"\"\r\nimport matplotlib.pyplot as plt\r\nplt.plot(range(10))\r\nplt.savefig(range10.png\")\r\nplt.savefig(\"range10.svg\")\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"demo.py\", line 5, in \u003cmodule\u003e\r\n plt.savefig(\"range10.svg\")\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/pyplot.py\", line 842, in savefig\r\n res = fig.savefig(*args, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/figure.py\", line 2311, in savefig\r\n self.canvas.print_figure(fname, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backend_bases.py\", line 2217, in print_figure\r\n **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 1318, in print_svg\r\n self._print_svg(filename, fh, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backend_bases.py\", line 1639, in wrapper\r\n return func(*args, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 1342, in _print_svg\r\n self.figure.draw(renderer)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py\", line 41, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/figure.py\", line 1864, in draw\r\n renderer, self, artists, self.suppressComposite)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/image.py\", line 132, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py\", line 41, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/cbook/deprecation.py\", line 411, in wrapper\r\n return func(*inner_args, **inner_kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/axes/_base.py\", line 2748, in draw\r\n mimage._draw_list_compositing_images(renderer, self, artists)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/image.py\", line 132, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py\", line 41, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/axis.py\", line 1169, in draw\r\n tick.draw(renderer)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py\", line 41, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/axis.py\", line 291, in draw\r\n artist.draw(renderer)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/artist.py\", line 41, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/lines.py\", line 854, in draw\r\n fc_rgba)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 683, in draw_markers\r\n oid = self._make_id('m', dictkey)\r\n File \"/home/daytonb/venv/lib64/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 440, in _make_id\r\n m = hashlib.md5()\r\nValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS\r\n```\r\n\r\n**Expected outcome**\r\n\r\nExpect no errors and an SVG named \"range10.svg\" that shows the same plot as a PNG named \"range10.png\".\r\n\r\n**Matplotlib version**\r\n\r\n * Operating system: CentOS Linux release 8.2.2004 (Core)\r\n * `fips-mode-setup --check` returns `FIPS mode is enabled`\r\n * Matplotlib version: 3.3.0\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): agg\r\n * Python version: 3.6.8\r\n * Jupyter version (if applicable): NA\r\n * Other libraries: \r\n```\r\n[daytonb@centos-s-1vcpu-1gb-nyc1-01 ~]$ venv/bin/python -m pip list\r\nPackage Version\r\n--------------- -------\r\ncycler 0.10.0\r\nkiwisolver 1.2.0\r\nmatplotlib 3.3.0\r\nnumpy 1.19.1\r\nPillow 7.2.0\r\npip 20.2.1\r\npyparsing 2.4.7\r\npython-dateutil 2.8.1\r\nsetuptools 49.2.1\r\nsix 1.15.0\r\n```\r\n\r\n","author":{"url":"https://github.com/daytonb","@type":"Person","name":"daytonb"},"datePublished":"2020-08-06T12:34:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/18192/matplotlib/issues/18192"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e3b8fe83-1d15-ceb7-f640-54118afd22f3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2FC:13CB91:9C2567:D438BC:6A520094 |
| html-safe-nonce | fd10ee3e3eac93fd4332da8634a8ed742c3164be5451a8b0a011526174cdda46 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkZDOjEzQ0I5MTo5QzI1Njc6RDQzOEJDOjZBNTIwMDk0IiwidmlzaXRvcl9pZCI6IjYxMzkzODk3OTQxNTU4ODg3ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2367379e24aab0102c9ae735aebca8a403897c4bf59cb7995d22c05909c67287 |
| hovercard-subject-tag | issue:674278725 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/18192/issue_layout |
| twitter:image | https://opengraph.githubassets.com/74d10284021fef774b4460724dccbeb7beded1b580483eab489aad01e73fdc8c/matplotlib/matplotlib/issues/18192 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/74d10284021fef774b4460724dccbeb7beded1b580483eab489aad01e73fdc8c/matplotlib/matplotlib/issues/18192 |
| og:image:alt | Bug report Bug summary If you use a FIPS (Federal Information Processing Standards) compliant Python install, then you cannot use plt.savefig to save an image in SVG format. This is because the Ren... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | daytonb |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width