plotly / plotly/plotly.py

mapbox static image export fails with tile server requiring client certificates

Open
#3,339 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

Hello,
I am using plotly.py on an internal network which does not have Internet connectivity. All connections on this network require client certificates, all servers have signed certificates for which we have a Certificate Authority bundle to verify those certificates.

I can create mapbox maps in our Jupyter environment which render appropriately, but when I try to export the map as an image using Kaleido I receive a chain of errors, concluding with error: ValueError: Transform failed with error code 525: Mapbox error. which references kaleido/scopes/plotly.py (here)

The HTTP 525 code is "SSL Handshake Failure". I'm using a 'white-bg' mapbox style and have confirmed no requests are going out looking for a mapbox server. When I remove the map tiles from the chart figure I can successfully export the map as a static image. Digging through the plotly code, it looks like the Kaleido base scope (here) is using chromium to render the map and then save it as an image.

The issue is that when I render the map in my browser, the browser has my client certificates loaded and the CA bundle loaded and it brings in the image tiles. When Plotly/Kaleido tries to retrieve the tiles using the underlying headless chromium, it's using a bare GET request and is being denied by the server (HTTP 525).

I've spent a lot of time looking for flags that could be passed to chromium to tell it to use my client certificates and the CA bundle, but (VERY surprisingly) there do not appear to be any.

A reproducible example is exactly like the Mapbox Map Layers - Base Tiles from the USGS: no token needed example, except that the server would require client certificates and could be verified with a custom CA bundle.

I would happily use a work-around if one was possible. Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Mapbox static export failure using the linked USGS base-tiles example in a network requiring client certificates. Read kaleido/scopes/plotly.py and kaleido/scopes/base.py, then determine what would allow headless Chromium to load the tiles with the client certificate and CA bundle; done means the chart exports successfully with those tiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.